Complete the code to print the class of the number 10.
puts 10.[1]
In Ruby, class is the method to get the class of an object.
Complete the code to call the upcase method on the string 'hello'.
puts 'hello'.[1]
The upcase method converts all letters in a string to uppercase.
Fix the error in the code to check if 5 is an object.
puts 5.[1](Object)
The is_a? method checks if an object is an instance of a class or its subclass.
Fill both blanks to create a hash where keys are strings and values are their lengths.
lengths = ['cat', 'dog', 'bird'].each_with_object({}) { |word, h| h[[1]] = [2] }
word.size also works but is not the expected answer here.The key is the word itself, and the value is its length using length.
Fill all three blanks to create a hash with uppercase keys and values greater than 3.
result = ['apple', 'bat', 'cat', 'dog'].each_with_object({}) { |word, h| if [3]; h[[1]] = [2] end }
word.size < 3 filters the wrong words.Keys are uppercase words, values are the original words, filtered by length greater than 3.
