ruby - How to solve in `basename': no implicit conversion of Array into String -


i filename viddlrb without extension. if i'm running get_names method youtube url i'm getting array. i'm doing that:

    file = viddlrb.get_names(url)     file.first     file.to_s     puts file     filename = file.basename(file, '.*') 

but if i'm running i'm getting:

in `basename': no implicit conversion of array string

maybe knows why breaks? thought file.to_s job.

when call file.to_s, it's returning result of string conversion, it's not modifying file variable. same call .first. consider example:

file = ["filename.txt"] file.first file.to_s => "[\"filename.txt\"]" puts file => ["filename.txt"] 

the easiest way solve call first , to_s within basename argument. so:

filename = file.basename(file.first.to_s, '.*') 

you alternately make variable before passing in.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -