Hi there,
I have a simple method:
def square(num)
num*num
end
how do I enter a number to feed in and puts or print the result?
Thank you
Hi there,
I have a simple method:
def square(num)
num*num
end
how do I enter a number to feed in and puts or print the result?
Thank you
Got it.
square (10)
…
You got it!
Consider also:
x = 10
print “The square of #{x} is #{square(x)}.\n”
And for more fun:
x = 9
print “#{x} squared is #{square(9)}.\nIn binary that’s %b.\n” % square(9)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs