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 178 views
1 answer 163 views
1 answer 244 views
1 answer 222 views
222 views asked Dec 20, 2020 by avibootz
1 answer 271 views
1 answer 227 views
2 answers 223 views
223 views asked Dec 20, 2020 by avibootz
...