Very rank beginner


#1

Help. I am a really new beginner looking at Ruby for the first time.
I was trying to go through the tutorial “Ruby in 20 minutes” on a
Windows XP
machine using fxri.

Some of the code does not work as in the examples. Who should I ask for
help?

Thanks for any suggestions (even flames are welcome )

Van!!


#2

Ropebender wrote:

Help. I am a really new beginner looking at Ruby for the first time.
I was trying to go through the tutorial “Ruby in 20 minutes” on a
Windows XP machine using fxri.

Some of the code does not work as in the examples. Who should I ask
for help?

Thanks for any suggestions (even flames are welcome )

Van!!

What site were you using the ruby tutorial from? What parts of the code
didn’t work, what were the problems or errors? If you’ve tried the
code and searched for answers, then you’d probably ask here.


#3

The tutorial was on http://www.ruby-lang.org/

It was the tutorial in the sidebar “Ruby in 20 minutes”

Worked fine until I tried to define a class Greeter. Instructions said
to
initialize Greeter with (name = “World”) and then define an object g to
set
the @name. It didn’t woork like the tutorial said.

=> nil

irb(main):033:0> class Greeter

irb(main):034:1> def initialize(name = “World”)

irb(main):035:2> end

irb(main):036:1> def say_hi

irb(main):037:2> puts “Hi #{@name}!”

irb(main):038:2> end

irb(main):039:1> def say_bye

irb(main):040:2> puts “Bye #{@name}!”

irb(main):041:2> end

irb(main):042:1> end

=> nil

irb(main):043:0> g = Greeter.new(“Pat”)

=> #Greeter:0x63075a4

irb(main):044:0> g.say_hi

Hi !

=> nil

irb(main):061:0> g = Greeter.new(“Andy”)

=> #Greeter:0x62e3924

irb(main):062:0> g

=> #Greeter:0x62e3924

irb(main):063:0>

Looks like the initialize never worked. Any suggestions?

“Tim G.” removed_email_address@domain.invalid wrote in message
news:H28bl.10476$removed_email_address@domain.invalid…


#4

“Ropebender” removed_email_address@domain.invalid writes:

irb(main):033:0> class Greeter

irb(main):034:1> def initialize(name = “World”)

irb(main):035:2> end

Looks like the initialize never worked. Any suggestions?

Indeed. def initialize(name = “World”) doesn’t initialize anything.
It just says that if you don’t give any argument to new, then it should
do as if you passwed “World”, and set the parameter accordingly.

You didn’t do anything with this parameter.
Try to add a
@name = name
somewhere…


#5

Ropebender wrote:

Sure enough …

I left that line out.  In the tutorial, the "@name" was in blue, and I
interpreted it as a response from ruby rather than a line I type in.Â
Sorry for the error.  I have a LOT to learn :)\

No need to apologize, sometimes it just takes some patience or an extra
set of eyes to find the problem. I’ve seen a lot of professional
coders about throw their system out the window (literally) because of a
simple thing they were missing after a day of coding with no breaks.
Sometimes you have to take a break and look at it with fresh eyes.


#6

irb(main):033:0> class Greeter

Don’t use irb. If you use Windows, the One Click Installer comes with
SciTE.exe.
Run that, and it will run your ruby for you each time you hit .


#7

Sure enough …

I left that line out. In the tutorial, the “@name” was in blue, and I
interpreted it as a response from ruby rather than a line I type in.
Sorry
for the error. I have a LOT to learn :)\

“Pascal J. Bourguignon” removed_email_address@domain.invalid wrote in message
news:removed_email_address@domain.invalid…

“Ropebender” removed_email_address@domain.invalid writes:

The tutorial was on http://www.ruby-lang.org/

It was the tutorial in the sidebar “Ruby in 20 minutes”


#8

Thanks for the tip … Another question:

When I write an xxx.rb program in Notebook and try to run it, the cmd
window will not stay open. On earlier versions of Windows you could
make a
.pif file to control if the window stayed open or closed, but in XP it
seems
they have taken that away. I looked up all the commands and opening
perameters I could find and can’t seem to find one that will cause the
CMD
window to wtay open after the program runs so I can see the results. I
either need to do that, or redirect the output to LPT1 so I can see what
I
did. Does SciTE allow you to read in and run a program from a file?

Thanks !

Van!!

“Phlip” removed_email_address@domain.invalid wrote in message
news:p4dbl.17653$removed_email_address@domain.invalid…


#9

A very rank beginner that doesn’t follow instructions! F5 you say.
Thanks
!! It works. Now all I have to do is learn the language.

“Phlip” removed_email_address@domain.invalid wrote in message
news:p4dbl.17653$removed_email_address@domain.invalid…


#10

Now I see, SciTE is an excelent looking universal Text Editor :slight_smile: What a
find! I would have never found it but for your hint. Thanks loads!
SciTE
will help in lots of ways… Notebook – never again :))

That answered the second question too, no, you can’t run the program
from a
text editor, Silly me. So I am left with the last one: how to keep
the
blasted window open or redirect the output.

Van!!
“Ropebender” removed_email_address@domain.invalid wrote in message
news:Rbpbl.8927$removed_email_address@domain.invalid…