tags:

views:

101

answers:

1

I wrote a program with three methods: def calculate, def compute, and def capture. Each method had some calculations in them. I want to get just the numeric answer of these methods and use them as a response to a question. I'm looking for it to say something like: Correct, 'calculate answer' and 'compute answer' and 'capture answer'. How would I do about doing this?

+1  A: 

I'll take a stab at it. Do you mean something like this?

Example code:

def calculate a
  a + 4
end

def compute a
  a * 2
end

def capture a
  a - 5
end

def question a
  puts "Correct, 'calculate #{calculate a}' and 'compute #{compute a}' and 'capture #{capture a}'"
end

Which, in irb gives:

>> question 17
Correct, 'calculate 21' and 'compute 34' and 'capture 12'
=> nil
Nick Desjardins