Before we get any further, we should make sure we understand the difference between numbers and digits. 12 is a number, but '12' is a string of two digits.
Let’s play around with this for a while:
puts 12 + 12 |
puts '12' + '12' |
puts '12 + 12' |
24 |
1212 |
12 + 12 |
How about this?
puts 2 * 5 |
puts '2' * 5 |
puts '2 * 5' |
10 |
22222 |
2 * 5 |
These examples are pretty clear. However, if you’re not too careful with how you mix your strings and your numbers, you might run into…
3.135.202.203