What do each of the following programs do?
(
all answers)
Question 1:
(
answer)
#!/usr/bin/ruby
def dostuff()
puts "dostuff"
end
class Test
def dostuff()
puts "Test.dostuff"
end
def run
self.dostuff
dostuff
end
end
t = Test.new
t.run
answer
Question 2:
(
answer)
#!/usr/bin/ruby
class Book
def open(path)
@file = open(path)
end
end
f = open("/dev/zero")
puts f
b = Book.new
b.open("/dev/zero")
puts b
answer