We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Can anyone help me with this Ruby script?
I am very new to ruby and I was hoping someone could help me. In the following script I am asking the user their favorite number. I would then like to add a one to their favorite number and suggest the resultant number as a better favorite number.
puts ‘What\’s your favorite number?’ number = gets.chomp.to_s puts ‘Your favorite number is ‘+number+’.’
If anyone could tell me how to this it would be great!
Hi,
Well, this site was designed with Ruby, so you may want to FunMail the programmer. His username on here is esconsult1. He can probably help you :)
puts ‘What\’s your favorite number?’ number = gets.chomp.to_s
new_number = number.to_i + 1
puts ‘Your favorite number is ‘+new_number+’.’
To explain a little bit more:
new_number = number.to_i + 1
Converts “number” which you converted to a string before with “gets.chomp.to_s” (you read the input from the terminal and converted it to a string so it can be appended to the other string that you are printing out with the other “puts” statement. Fine.
However, a short way to do all that is also:
number = gets.chomp.to_i + 1 puts ‘ A better number is ‘ + number.to_s
-
please help me find this photo anyone know? - 2 Answers
I cant seem to remember where I go this from anyone know? I would like to use it for something so please if anyone knows let ...
-
Can anyone help me with an AIM problem? - 1 Answers
okay, so yesterday my aim started not displaying my IMs for some reason. I know I am receiving IMs because I will have my awa...
-
Can anyone help with my Samsung Lt205 digital camera problem? - 1 Answers
So now when i take pictures they either come out how it's shown (with just taking a regular picture and not doing anything fu...
-
Is anyone else using ruby on rails to build a large scale site? - 2 Answers
FunAdvice is developed entirely in Ruby on Rails. This month, we're on track to generate north of 600,000 unique visitors, an...
-
Java script - 1 Answers
How to turn on your java script in windows xp?
-
What to do? Problems with Ipod Touch :( Can anyone help? - 2 Answers
I got an Ipod touch for christmas and have been having problems with it. It copies from the itunes library not only songs I'v...
-
Can anyone help me out with my Turtle Beach P11 problem? - 4 Answers
I am using an HDTV and I put the USB to power the headset in the PS3 like i should and put the two splitters in the back of m...
-
Can anyone here help me with building a website? - 1 Answers
Im using a site to do it now, but i wanna make one where like people can talk to one another on it at a certain page. And thi...
-
Anyone have a Samsung Blackjack PDA? - 2 Answers
Does anyone else have a samsung Black Jack pda ? If yes , funmail me I need help . >_<
-
Can't get into my myspace, help anyone? - 3 Answers
About two weeks ago I was unable to log into my account, so I figured it was just another glitch in a social site and that it...
Developer Helps
Web Development, Programming, Software Development
Cash App Helps
Financial Services, Technology, Customer Support
MXZ SMM Panel Script
Social Media Marketing, SEO, Online Marketing
Help Number
Technology, Internet, Domain Name
Sky Help Service
Tech Support Services, Email Services, Password Recovery Services