ruby echoinput.rb < echoinput.rb
at the command prompt (after installing Ruby) to display the program.
ruby sum.rb
5
4
3
Control-Z
(where the last line is holding down the control key and pressing a Z)
to print a 12.
irb> load 'phones.rb'
irb> test_phone_book
class Pair
attr_reader :x, :y
attr_writer :x, :y
# two Pairs are defined to be the same if their products are:
def ==(other)
@x * @y == other.x * other.y
end
end
Using it:
irb(main):042:0> a = Pair.new; a.x = 5; a.y = 6
=> 6
irb(main):043:0> b = Pair.new; b.x = 3; b.y = 10
=> 10
irb(main):044:0> a == b
=> true
irb(main):045:0> b.y = 9
=> 9
irb(main):046:0> a == b
=> false