Forum: Ruby Why the speed?

Posted by Jesper Bukkehave (quale_boy)
on 2013-02-07 16:44
Attention!! Noob warning :)

Hello everybody, first of all I just got Ruby v. 1.9.3p374 (latest I
could find), Notepad ++ and the book "Pragmatic Programming 1.9"

And im thinking that im of to a great start. But nooo, whem i make a
very simple prog.

Like:

puts 1+2

and save that as 3.rb then run the prog. It shows for less than a
millisecond which means, I know I did it right but cant see the result
because of the speed...

Arrrgh please help!

Btw cool forum and nice little puzzle to get an account :) can´t wait to
get started and see where Ruby takes me.

-Quale_Boy
Posted by Hans Mackowiak (hanmac)
on 2013-02-07 16:56
1) there is an newer ruby patchlevel available
2) it looks that you are on windows, you need to call your script from 
cmd
otherwise its does not wait for the window to close
Posted by Jesper Bukkehave (quale_boy)
on 2013-02-07 17:16
Attachment: Untitled.jpg (91,8 KB)
1) do I have to install it, or can I wait?

2) I tried to run it from cmd but this is what i get. (see attatchment)

What do you mean by this?

"otherwise its does not wait for the window to close"

And thank you :)
Posted by "Hajdú Zoltán" <janicetr@fastmail.fm> (Guest)
on 2013-02-07 17:25
(Received via mailing list)
On Thu, Feb 7, 2013, at 17:16, Jesper Bukkehave wrote:
> 2) I tried to run it from cmd but this is what i get. (see attatchment)

Give "ruby test.rb" a try :)

Bests:

Zoltan
Posted by Joel Pearson (virtuoso)
on 2013-02-07 17:33
If you installed ruby using the "ruby install for windows", then there's 
a special CMD shortcut in the start menu which will correctly interpret 
commands like "irb" and instructions to execute a ruby file.
if you want to double-click the file, but not close immediately after 
running, then you can add "gets" to the end of your file.
Posted by Jesper Bukkehave (quale_boy)
on 2013-02-07 17:36
"Hajdú Zoltán" <janicetr@fastmail.fm> wrote in post #1095785:
>
> Give "ruby test.rb" a try :)
>
> Bests:
>
> Zoltan

Thanks that helped. Im also very new to CMD soooo :)that figures.

I anyone has good advice for an extreme beginner, please don´t be shy I 
want to be good at this.

Besides the book I got I am supplying with this page:

<link>http://www.codecademy.com/courses/ruby-beginner-en...

It is a very nice step-by-step intro to Ruby. I recommend it for most 
beginners like me.
Posted by Jesper Bukkehave (quale_boy)
on 2013-02-07 17:41
"Joel Pearson"

Yessss :) very nice! thank you
Posted by stomar (Guest)
on 2013-02-07 18:30
(Received via mailing list)
Am 07.02.2013 17:34, schrieb Joel Pearson:

> if you want to double-click the file, but not close immediately after
> running, then you can add "gets" to the end of your file.

Bad practice! That means that you have to press enter always,
even when you run the program from the prompt (which is the
normal way to do it).

I would rather recommend to get acquainted with the command prompt.

stomar
Posted by Jesper Bukkehave (quale_boy)
on 2013-02-07 18:54
> I would rather recommend to get acquainted with the command prompt.
>
> stomar

I am already working on it :) this is fun.

Fist program finished, it´s not perfect but I am learning:

print "What's your first name?"
first_name = gets.chomp
first_name.capitalize!
puts "So your name is #{first_name} eh :)"

print "What's your last name?"
last_name = gets.chomp
last_name.capitalize!
puts "Really, interesting!"

print "What city are you from?"
city = gets.chomp
city.capitalize!
puts "I hear that it is very lovely during the summer."

print "What state or province are you from?"
state = gets.chomp
state.upcase!
puts "I did not know that"

puts "So your name is #{first_name} #{last_name} and you're from a city
called #{city}, #{state}!"
gets

Feel free to edit and cut into little pieces.

It is really nice to be able to learn something like Ruby so fast. So 
easy (for now) I started 3 hours ago and now I am able to create very 
simple and very small programs. Thanks!
Posted by Joel Pearson (virtuoso)
on 2013-02-07 22:14
Good start. You could try method chaining next:

first_name = gets.chomp.capitalize
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.