q = {"It", "was", "the", "best", "of", "times", "it", "was", "the", "worst", "of", "times"}
write an expression to return
wasworsttimes
without using any character or string literals.
Can someone help me figure out how to do this?
q = {"It", "was", "the", "best", "of", "times", "it", "was", "the", "worst", "of", "times"}
write an expression to return
wasworsttimes
without using any character or string literals.
Can someone help me figure out how to do this?
I'm pretty sure the hash should be {"it", "was",...}
(lower case i
at the beginning).
Then this literal will create the following hash {"it"=>"was", "the"=>"worst", "of"=>"times"}
.
Note that the words you're supposed to extract are the value of the hash. So you can just use Hash
's values
method to get them and Array
's join
method to turn the array of values into a string.