Complete the code to get a method object from the string 'hello'.
str = 'hello' method_obj = str.[1](:upcase)
send instead of method returns the result, not a method object.call directly on the string is invalid.The method method returns a method object for the given method name.
Complete the code to call the method object and get the uppercase string.
str = 'hello' method_obj = str.method(:upcase) result = method_obj.[1]()
send on a method object is invalid.apply or invoke are not Ruby methods.The call method invokes the method object and returns the result.
Fix the error in the code to correctly get the length method object from an array.
arr = [1, 2, 3] length_method = arr.[1](:length)
send calls the method instead of returning the method object.call on the array is invalid.The method method returns a method object; send calls the method immediately.
Fill both blanks to create a method object for 'reverse' and call it.
text = 'world' reverse_method = text.[1](:reverse) result = reverse_method.[2]()
send instead of method returns the result immediately.send or define_method to call the method object is invalid.First, get the method object with method, then call it with call.
Fill all three blanks to get the 'capitalize' method object from a string, call it, and store the result.
word = 'ruby' capitalize_method = word.[1](:capitalize) result = capitalize_method.[2]() puts [3]
send instead of method to get the method object.Use method to get the method object, call to run it, and print the stored result.