+ 2
Fill in the blanks ????
Fill in the blanks to instantiate an object of the class Cat, passing to the constructor the value 12. Then call the Meow method for that object: Cat c= Cat(); Meow0;
9 Answers
+ 15
Cat c = new Cat(12);
c.Meow();
You can find explanations in the comments to the lessons.
+ 1
Fill in the blanks to instantiate an object of the class Person, passing the value 42 to it. Then call the "speak" method for that object.
Answer
ob = Person.new (42)
ob.speak
+ 1
Drag and drop from the options below to define a module Test, which includes a class method "sum". Then call the method.
Answer:
module Test
def self.sum
#some code
end
end
Test.sum
+ 1
Cat c =
new
Cat(
12
);
c.
Meow();
0
Fill in the blanks to define a module "Stuff", with a class method "shuffle" and call it.
Answer:
module Stuff
def self.shuffle
end
end
Stuff.shuffle
0
Fill in the blanks to create a Proc called sum that takes two parameters and outputs their sum. Call it for values 8 and 5.
Answer:
sum = Proc.
new do |x, y|
puts x + y
end
puts sum.call 8, 5
0
Cat c = new Cat(12);
c.Meow();
0
Fill in the blanks to create a function outputting the sum of the two parameters.
add(x, y) {
- 1
Fill in the blanks to make the code work