# lec 19 in class # comments start with the hashtag (octothorp) symbol "#" class Hello def my_first_method puts "Hello, World!" end end x = Hello.new x.my_first_method # generally don't use ";" at the end of a line in REPL (irb) class A def m1 34 end def m2 (x, y) z = 7 if x > y false else x + y * z end end end class B def m1 4 end def m3 x x.abs * 2 + self.m1 end end class C def m1 print "hi " self end def m2 print "bye " self end def m2 print "yo" self end def m3 print "\n" self end end # newlines often are significant in Ruby syntax # indentation never matters though class D def m1 @foo = 0 end def m2 x @foo = @foo + x @bar = 0 end def foo @foo end end class E def initialize(f=0) # Ruby has default arguments @foo = f end def m2 x @foo += x @bar = 0 end def foo @foo end end class F # we now add in a class-variable, class-constant, and class-method Zachs_Age = 33 def self.reset_bar @@bar = 0 end def initialize(f=0) @foo = f end def m2 x @foo += x @@bar += 1 end def foo @foo end def foo= x @foo = x end def bar @@bar end end