Created
July 24, 2013 15:39
-
-
Save alxjrvs/6071729 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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