String Quiz
u = " unity "
i = "in the "
k = "kangaroo community"
Given the above variables, how might one build the string "1 unity in the kangaroo community"? You may select more than one option.
1.to_s + u + i + k1.to_s + " unity " << i << k1.to_s + " " + k[-5..-1] + " " + i + k"1 unity in the kangaroo community" (although some are more elegant than others). The last option leverages the fact that k[-5..-1] == "unity", i.e., that "community" is a kangaroo word of "unity.""divisions divide into divisions".split
What does the above code snippet return?
["", "visions ", "vide into", "visions"]["divisions", "divide", "into", "divisions"]"divisions divide into divisions""vsons ve nto vsons"split divides the string into an array using the default delimiter of ' '."divisions divide into divisions".split('di')
What does the above code snippet return?
["", "visions ", "vide into", "visions"]["divisions", "divide", "into", "divisions"]"divisions divide into divisions""vsons ve nto vsons"split divides the string into an array along the delimiter 'di'."divisions divide into divisions".upcase.downcase
What does the above code snippet return?
["", "visions ", "vide into", "visions"]["divisions", "divide", "into", "divisions"]"divisions divide into divisions""vsons ve nto vsons"downcaseis the last method invoked in the method chain, making the string
entirely lowercase."redivider" * 3
What does the above code snippet return?
"redivider"["r", "e", "d", "i", "v", "i", "d", "e", "r"]"redividerredividerredivider""redivider redivider redivider""redivider".reverse
What does the above code snippet return?
"redivider"["r", "e", "d", "i", "v", "i", "d", "e", "r"]"vrriieedd"2"redivider" is a palindrome, i.e., it's equivalent to its reverse."redivider".split("").reverse
What does the above code snippet return?
"redivider"["r", "e", "d", "i", "v", "i", "d", "e", "r"]"vrriieedd"2chars method returns an array of the characters in "redivider". Reversing those characters has no effect given that "redivider" is a palindrome."redivider".split("").sort.reverse.join
What does the above code snippet return?
"redivider"["r", "e", "d", "i", "v", "i", "d", "e", "r"]"vrriieedd"2"redivider" is divided into an array of its characters, which is then
sorted alphabetically and reversed and combined into a string.