What is the return value for …

Technology CommunityCategory: RubyWhat is the return value for …
VietMX Staff asked 3 years ago
Problem

For the class ABC the given as:

class ABC
  def xyz
    puts "xyz in ABC"
  end
end

What is the return value for:

  • ABC::new::xyz
  • ABC::new.xyz
  • ABC.new::xyz
  • ABC.new.xyz

All the statements for the invocation of the xyz method through the object are valid.

When run through IRB:

irb(main):001:0> ABC::new::xyz
xyz in ABC
=> nil
irb(main):002:0> ABC::new.xyz
xyz in ABC
=> nil
irb(main):003:0> ABC.new::xyz
xyz in ABC
=> nil
irb(main):004:0> ABC.new.xyz
xyz in ABC
=> nil