December 2014
Beginner
336 pages
7h 41m
English
You have been using the = character to name variables and set them to numbers or strings. We’re now going to blow your mind again by showing you how to use = and a new Ruby word return to set variables to be a value from a function. There will be one thing to pay close attention to, but first type this in:
ex21.rb
1 def add(a, b) 2 puts "ADDING #{a} + #{b}" 3 return a + b 4 end 5 6 def subtract(a, b) 7 puts "SUBTRACTING #{a} - #{b}" 8 return a - b 9 end 10 11 def multiply(a, b) 12 puts "MULTIPLYING #{a} * #{b}" 13 return a * b 14 end 15 16 def divide(a, b) 17 puts "DIVIDING #{a} / #{b}" 18 return a ...
Read now
Unlock full access