Forum: Ruby Very rank beginner.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ropebender (Guest)
on 2009-01-13 23:35
(Received via mailing list)
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!!
Tim G. (Guest)
on 2009-01-13 23:55
(Received via mailing list)
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.
Ropebender (Guest)
on 2009-01-14 01:36
(Received via mailing list)
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...
Pascal J. Bourguignon (Guest)
on 2009-01-14 01:40
(Received via mailing list)
"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...
Ropebender (Guest)
on 2009-01-14 01:55
(Received via mailing list)
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"
Tim G. (Guest)
on 2009-01-14 02:55
(Received via mailing list)
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.
Phlip (Guest)
on 2009-01-14 05:40
(Received via mailing list)
> 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 <F5>.
Ropebender (Guest)
on 2009-01-14 19:20
(Received via mailing list)
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...
Ropebender (Guest)
on 2009-01-14 19:30
(Received via mailing list)
Now I see, SciTE is an excelent looking universal Text Editor :)  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...
Ropebender (Guest)
on 2009-01-14 19:53
(Received via mailing list)
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...
This topic is locked and can not be replied to.