From: Charlie Ca on
Hello World,
I am new to programming and am writing a program in ruby that serves as
a tutorial for absolute beginners. It's heavily reliant on if & else. I
was wondering if there is a method for exiting a program. Here is the
Context;

puts ' If you would like to begin, press enter.'
confirm1 = gets.chomp
if confirm1 == ''
puts 'OK, Lets begin!'
else
puts 'Try pressing enter this time.'
gets.chomp
if gets.chomp == ''
puts 'Press enter twice'
else
puts 'Next time press enter ;( '
end
end
puts ' If you are reading this you have already downloaded'
puts ' the interactive ruby console with the' #...


When they don't press enter the 2nd time, I would like to exit the
program. Thanks, Charlie
--
Posted via http://www.ruby-forum.com/.

From: Marnen Laibow-Koser on
Charlie Ca wrote:
> Hello World,
> I am new to programming and am writing a program in ruby that serves as
> a tutorial for absolute beginners. It's heavily reliant on if & else. I
> was wondering if there is a method for exiting a program. Here is the
> Context;
>
> puts ' If you would like to begin, press enter.'
> confirm1 = gets.chomp
> if confirm1 == ''
> puts 'OK, Lets begin!'
> else
> puts 'Try pressing enter this time.'
> gets.chomp
> if gets.chomp == ''
> puts 'Press enter twice'
> else
> puts 'Next time press enter ;( '
> end
> end
> puts ' If you are reading this you have already downloaded'
> puts ' the interactive ruby console with the' #...
>
>
> When they don't press enter the 2nd time, I would like to exit the
> program. Thanks, Charlie

If you need to ask the mailing list a question like this, then you are
not ready to be writing Ruby tutorials. Sorry, but that's the way it
is.
Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
marnen(a)marnen.org
--
Posted via http://www.ruby-forum.com/.

From: Charlie Ca on
Marnen Laibow-Koser wrote:
> If you need to ask the mailing list a question like this, then you are
> not ready to be writing Ruby tutorials. Sorry, but that's the way it
> is.
> Best,
> -- 
> Marnen Laibow-Koser
> http://www.marnen.org
> marnen(a)marnen.org

Thanks for the encouragement. I guess I should stick to 'Hello World'
programs.
--
Posted via http://www.ruby-forum.com/.

From: Eric Christopherson on
On Wed, Feb 10, 2010 at 5:53 PM, Marnen Laibow-Koser <marnen(a)marnen.org> wrote:
> If you need to ask the mailing list a question like this, then you are
> not ready to be writing Ruby tutorials.  Sorry, but that's the way it
> is.

That's a little harsh, although it would probably be true if the
poster was actually *writing* the tutorial. I thought that on first
reading too, but after I read it again I figured he meant he was
writing a program as a solution to a problem in a tutorial he's going
through.

Anyway, Charlie, the method is simply 'exit'. It's a class method of
the Kernel module, so it will be invoked if you don't specify a
receiver object.

From: Marnen Laibow-Koser on
Eric Christopherson wrote:
> On Wed, Feb 10, 2010 at 5:53 PM, Marnen Laibow-Koser <marnen(a)marnen.org>
> wrote:
>> If you need to ask the mailing list a question like this, then you are
>> not ready to be writing Ruby tutorials. �Sorry, but that's the way it
>> is.
>
> That's a little harsh, although it would probably be true if the
> poster was actually *writing* the tutorial. I thought that on first
> reading too, but after I read it again I figured he meant he was
> writing a program as a solution to a problem in a tutorial he's going
> through.

Oh, if that's the case, then yes, my response was uncalled-for. I did
interpret the OP's original post as saying he was *creating* a tutorial.

>
> Anyway, Charlie, the method is simply 'exit'. It's a class method of
> the Kernel module, so it will be invoked if you don't specify a
> receiver object.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
marnen(a)marnen.org
--
Posted via http://www.ruby-forum.com/.

 |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Can't install hpricot gem
Next: fastest readline method