In Ruby, you can use the *
operator to multiply two numbers together.
Here's an example of multiplying two numbers in Ruby:
main.rb43 chars5 lines
In this example, a
is assigned the value 3, b
is assigned the value 5, and c
is the product of a
and b
. The puts
method is used to output the value of c
.
You can also perform multiplication directly in the puts
statement:
main.rb25 chars2 lines
gistlibby LogSnag