def explain
puts "double quote equivalents"
p "a b c", %Q{a b c}, %Q(a b c), %(a b c), %<a b c>, %!a b c! # & etc
puts
puts "single quote equivalents"
p 'a b c', %q{a b c}, %q(a b c), %q<a b c>, %q!a b c! # & etc.
puts
puts "single-quote whitespace split equivalents"
p %w{a b c}, 'a b c'.split, 'a b c'.split(" ")
puts
puts "double-quote whitespace split equivalents"
p %W{a b c}, "a b c".split, "a b c".split(" ")
puts
end
explain
def extra_credit
puts "Extra Credit"
puts
test_class = Class.new do
def inspect() 'inspect was called' end
def to_s() 'to_s was called' end
end
puts "print"
print test_class.new
puts "(print calls to_s and doesn't add a newline)"
puts
puts "puts"
puts test_class.new
puts "(puts calls to_s and adds a newline)"
puts
puts "p"
p test_class.new
puts "(p calls inspect and adds a newline)"
puts
end
extra_credit