ruby - Split string variable into an array -


just wondering how split string variable letter letter , make array

my word variable randomly selected word array of words:

word = $file_arr[rand($file_arr.length)] 

how split word individual letters , add them array?

example: if word pulls word "hello" $file_arr how make array like: ["h", "e", "l", "l", "o"] out of word variable

all i've been able find online people doing strings type in , splitting on comma, how variable?

use string#chars

http://ruby-doc.org/core-2.0.0/string.html#method-i-chars

2.3.1 :009 > "hello world".chars => ["h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"] 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -