Skip to content

Instantly share code, notes, and snippets.

@alxjrvs
Created July 24, 2013 15:39
Show Gist options
  • Save alxjrvs/6071729 to your computer and use it in GitHub Desktop.
Save alxjrvs/6071729 to your computer and use it in GitHub Desktop.
class Adder
#we create a getter and setter for the left_side and ride_side variables
attr_accessor :left_side, :right_side
# So we set the base values for each instance here.
def initialize(left_side, right_side)
@left_side = left_side
@right_side = right_side
end
def get_sum
# This calls the getters set in line 4 and returns the sum
left_side + right_side
end
def add_another(num)
# This is not well written code, but I am proving a point.
# Set the 'left_side' variable.
left_side = left_side + right_side
left_side + num
end
def better_add_another(num)
# call the get_sum method directly!
get_sum + num
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment