How to print variable in string with Ruby

2 Answers

0 votes
x = 345

puts "x = #{x}"



# run:
#
# x = 345
#

 



answered Dec 19, 2020 by avibootz
0 votes
x = 456
y = 981

puts "#{x} + #{y} = #{x+y}"



# run:
#
# 456 + 981 = 1437
#

 



answered Dec 19, 2020 by avibootz

Related questions

1 answer 183 views
1 answer 167 views
1 answer 248 views
1 answer 225 views
225 views asked Dec 20, 2020 by avibootz
1 answer 272 views
1 answer 231 views
2 answers 223 views
223 views asked Dec 20, 2020 by avibootz
...