[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

new to ruby

Imraan Moolla

12/10/2007 9:56:00 AM

why does my while loop never end?

puts 'Please enter a number:'
number = gets.chomp.to_i
while number != ''
if number > 0
puts 'You have entered a number greater than 0'
end
puts 'Please enter a number'
number = gets.chomp.to_i
end
puts 'Goodbye!'
--
Posted via http://www.ruby-....

5 Answers

Peña, Botp

12/10/2007 10:15:00 AM

0

RnJvbTogSW1yYWFuIE1vb2xsYSBbbWFpbHRvOmltb29sbGFAZ21haWwuY29tXSANCiMgd2h5IGRv
ZXMgbXkgd2hpbGUgbG9vcCBuZXZlciBlbmQ/DQoNCmNoZWNrIHlvdXIgd2hpbGUgY29uZGl0aW9u
LCBwbHMuDQogDQojIHB1dHMgJ1BsZWFzZSBlbnRlciBhIG51bWJlcjonDQojIG51bWJlciA9IGdl
dHMuY2hvbXAudG9faQ0KDQpudW1iZXIgaXMgYW4gaW50ZWdlcg0KDQojIHdoaWxlIG51bWJlciAh
PSAnJw0KDQp0aGVuIHlvdSdyZSBjb21wYXJpbmcgaXQgdyBhIHN0cmluZw0K

Thind, Aman

12/10/2007 10:20:00 AM

0


Hello,

Is there any other source where I could download the gem
activerecord-sybase-adapter.

I have been trying to access http://gems.rubyo... all day, which
hosts these adapters according to
http://weblog.rubyonrails.org/2007/10/1/adapter-gems... but to no
avail.

http://gems.rub... didn't yield anything either.

I am upgrading to rails 2.0 and this is holding me back.

Many Thanks,
Aman



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.




Mark Woodward

12/10/2007 10:21:00 AM

0


Hi Imraan,

On Mon, 10 Dec 2007 04:55:51 -0500
Imraan Moolla <imoolla@gmail.com> wrote:

> why does my while loop never end?
>
> puts 'Please enter a number:'
> number = gets.chomp.to_i

casting to an integer

> while number != ''

this is a string
(while number > 0)

> if number > 0
> puts 'You have entered a number greater than 0'
> end
> puts 'Please enter a number'
> number = gets.chomp.to_i

casting to an integer

> end
> puts 'Goodbye!'


cheers,


--
Mark

Codeblogger

12/10/2007 10:24:00 AM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Because gets.chomp.to_i will never be an empty string ('').

''.to_i
--> 0

nil.to_i
--> 0

Regards,
Nicolai

Imraan Moolla

12/10/2007 10:29:00 AM

0

Thank you all. I understand now! :)

Mark Woodward wrote:
> Hi Imraan,
>
> On Mon, 10 Dec 2007 04:55:51 -0500
> Imraan Moolla <imoolla@gmail.com> wrote:
>
--
Posted via http://www.ruby-....