String can't be coerced into Fixnum (TypeError)

string can phone
silly string can
best string for tin can phone
how to make a string phone
how does a string telephone work
do tin can phones work
can and string phone gif
goofy string

I wrote the basic codes below

puts ' Hi there , what is your favorite number ? '
number = gets.chomp
puts number + ' is beautiful '
puts 1 + number.to_i + 'is way better'

But when I run it,I get the error "String can't be coerced into Fixnum (TypeError)". How do I correct this error please?


You cannot add a String to a number. You can add a number to a String, since it is coerced to a String:

'1' + 1
# => "11"
1 + 1
# => 2
1 + '1'
# TypeError!

Since I suspect you want to show the result of adding 1 to your number, you should explicitly cast it to string:

puts (1 + number.to_i).to_s + ' is way better'

or, use string interpolation:

puts "#{1 + number.to_i} is way better"

StringCan Interactive: Digital Marketing Scottsdale, Silly String Can found in: Goofy String, 1.8 oz. Cans, Crazy and fun, goofy string is a kid favorite for any celebration or for just whatever! Great for birthday  String & Can Audio Post House with a combined 7 Wins and 16 Emmy Nominations, 1 Win and 4 CAS Awards Nominations and 1 Edward R. Murrow Award win 875 Avenue of the Americas, Floor 19 New York, NY, 10001 United States


String can't be coerced into Integer usually happens, when you try to add a string to a number. since you want to add 1 to your number and concatenate it with a string "is way better". you have to explicitly cast the result you got from adding 1 to your number to a string and concatenate it with your string "is way better".

you can update your code to this:

puts (1 + number.to_i).to_s + " " + 'is way better'

Tin can telephone, String & Can. Audio Post House with a combined 7 Wins and 16 Emmy Nominations, 1 Win and 4 CAS Awards Nominations and 1 Edward R. Murrow Award win. Here at String & Can, we are a team of highly-trained and skilled, remote-ready interpreting professionals, but when you work with us, you get so much more. The following services are included at no additional cost: Remote Interpreting needs assessment for your event/organization


Assuming that the numbers are natural numbers:

number = gets.chomp
puts "#{number} is beautiful ", "#{number.succ} is way better"

Silly String Can, Here at String & Can, we are a team of highly-trained and skilled, remote-ready interpreting professionals, but when you work with us, you get so much more. This item: SILLY Crazy Party STRING in a can - 3 cans per order $8.70. Only 8 left in stock - order soon. Ships from and sold by Discount Party and Novelty.


You might find the results of entering 'xyz' as an input surprising.

This discussion for determining if your input string is a number may be helpful.

String & Can, this wacky string is so silly & fun, it's a must for parties, surprises, & anything else ur brilliant mind can dream up. it's string in a can! colors: pink, yellow, green,  A tin can telephone is a type of acoustic speech-transmitting device made up of two tin cans, paper cups or similarly shaped items attached to either end of a taut string or wire. It is a particular case of mechanical telephony, where sound is converted into vibrations along liquid or solid medium. These vibrations are transmitted along the medium and then reconverted back to sound. In the case of tin can telephone the medium is a string.


String & Can Multilingual Online – Full Service Interpretation. Online., String Can Theory. POSTPONED An original play by Sharleigh Thomson Presented by Players' Ring Theatre. There are two reasons that Elizabeth Farren is  Find if a given string can be represented from a substring by iterating the substring “n” times Given a string ‘str’, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.


wacky string can, Given two strings str1 and str2, check if str2 can be formed from str1. Example : Input : str1 = geekforgeeks, str2 = geeks Output : Yes Here, string2 can be formed​  String can now be used to craft crossbows and a loom. The texture of string has now been changed. 18w45a: String can now be used to craft scaffolding. 18w47a: String can now be found inside pillager outpost chests. Upcoming Java Edition; 1.16 20w09a: String can now be obtained through bartering with piglins. 20w13a: Striders now drop string upon death. 20w16a


String Can Theory, Description Text strings can be represented in two ways. you can use the String data type, which is part of the core as of version 0019, or you can make a string out of an array of type char and null-terminate it. This page described the latter method.