I am beginner in ruby language so, I tried to print this line
a = 2
z = "A"
print a * z
then I get this Error
Traceback (most recent call last):
20: from /usr/local/bin/irb:23:in `<main>'
19: from /usr/local/bin/irb:23:in `load'
18: from /var/lib/gems/2.7.0/gems/irb-1.3.7/exe/irb:11:in `<top (required)>'
1: from (irb):24:in `<main>'
(irb):24:in `*': String can't be coerced into Integer (TypeError)
But when I tried to using this code it's work in the right way and I didn't receive any error
puts z * 2
or
puts "A" * 2
or
z*a
HERE I DON'T USE PRINT, PUTS, P
so why I got the error in the beginning example and what is the Mechanism of Action of two code