String Quiz
str = "string"
puts str[-1] # .............. A
puts str[5] # ............... B
puts str[str.length - 1] # .. C
puts str[0..4] # ............ D
Which of the above expressions will print "g"?
str = "string"
puts str[2, 3] # ... A
puts str[2..3] # ... B
puts str[3, 2] # ... C
puts str[3..4] # ... D
Which of the above expressions will print the same slice of "string"?
name = "Sabine"
puts 'Hello ' + name + ', how are you today?' # ... A
puts "Hello " + name + ", how are you today?" # ... B
puts 'Hello #{name}, how are you today?' # ........ C
puts "Hello #{name}, how are you today?" # ........ D
Which of the above expressions will print identical strings?