Expert
What does the following code do?
foobar = []
class << foobar
def foo
"Hello World"
end
end
Author: HivebriteStatus: PublishedQuestion passed 296 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!
0
What is the output of the following Ruby code? `numbers = [1, 2, 3, 4, 5]`
`numbers.each { |n| puts n }`
`numbers.map { |n| puts n }`1
How to change the value of a string in Ruby2
What is the output of the following code?
class Person
attr_accessor :name
end
person = Person.new
person.name = 'John'
puts person.name
0
Write a Ruby program that prints the sum of two numbers1
How to add a key-value pair to a hash in Ruby1
What is the output of the following code?
class A
def method1
puts 'method1'
end
private
def method3
puts 'method3'
end
end
obj = A.new
obj.method1
obj.method30
What is the difference between include, extend and prepend in Ruby?