How to convert a string to an array of chars in ruby? -


let's have string "hello" , want array of chars in return ["h", "e", "l", "l", "o"].

although it's simple question couldn't find direct answer.

there several ways array out of string. #chars shortcut thestring.each_char.to_a direct in opinion

>> "hello".chars => ["h", "e", "l", "l", "o"] 

the other ways same result "hello".split(//) less intention-revealing.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -