oclockvn
3/21/2019 - 4:12 PM

Ruby method

Ruby method

def is_even?(val) #method name ends with `?` return boolean
  val % 2 == 0
end

def add_val(x, y)
  x + y #return at last statement
end

is_even? 2 #no need the `()`
a = add_val(1, 2) #a = 3