A new lesson


#1

def add(a, b)
a+b
end

def mult(a, b)
a*b
end

x = mult(add(2, 3), add(4, 7))
puts x

outputs 55

Well I dnt get this:
Why did this disappear?
def mult (a,b)
a*b
end
:cry:


#2

To understand this, start from the innermost parenthes going outward,

Your two inner add functions sum will be 5 and 11 making your code now look like,

mult(5, 11)

And as you know 5*11 = 55


#3

Thank you so much,can i share this description
with others on another website?It is really useful


#4

Maybe just give them a link to this post and they can check it out here :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.