8 Replies - 3938 Views - Last Post: 02 March 2011 - 06:13 PM Rate Topic: -----

#1 kkslider55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 19-February 11

Attempting to learn Ruby, ran into a problem.

Posted 19 February 2011 - 11:52 AM

Hello. I am extremely sorry if this is misplaced, and if that is the case, just tell em so and I'll seek help elsewhere.

Basically, I am trying to learn Ruby. I have been following This tutorial, and I've ran into a problem with the very first step...

Basically, I can't get command window to do anything. It says to type the following into an editor and save it as p001hello.rb

# p001hello.rb  
puts 'Hello'  
p 'hello'  
print 'hello' 


And I did. Then it tells me to type the top line into the command window, and the bottom should show. So I type in:

c:\rubyprograms> ruby p001hello.rb 


and I get:

-1:1: syntax error, unexpected $undefined, expecting tSTRING_CONTENT or tSTRING_D
BEG or tSTRING_DVAR or tSTRING_END
C:\rubyprograms> ruby p001hello.rb
   ^
-:1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '<'
C:\rubyprograms> ruby p001hello.rb
                               ^


So... If anybody could shed some enlightenment on what I did wrong, I'd be very grateful. Ruby seems like a very exciting language to learn, and it would be tragic if such a small thing kept me from learning.

Is This A Good Question/Topic? 0
  • +

Replies To: Attempting to learn Ruby, ran into a problem.

#2 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 911
  • View blog
  • Posts: 3,180
  • Joined: 12-May 09

Re: Attempting to learn Ruby, ran into a problem.

Posted 19 February 2011 - 02:40 PM

That's interesting - I typed up the same program with the same name and it ran successfully. That definitely looks like ruby interpreter errors. What version of ruby are you running? This can be found by typing ruby -v at the command prompt.

This post has been edited by xclite: 19 February 2011 - 02:40 PM

Was This Post Helpful? 0
  • +
  • -

#3 kkslider55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 19-February 11

Re: Attempting to learn Ruby, ran into a problem.

Posted 19 February 2011 - 04:12 PM

ruby 1.9.2p136
Was This Post Helpful? 0
  • +
  • -

#4 kkslider55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 19-February 11

Re: Attempting to learn Ruby, ran into a problem.

Posted 25 February 2011 - 02:02 AM

Just bumping along, hoping someone can help.
Was This Post Helpful? 0
  • +
  • -

#5 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 911
  • View blog
  • Posts: 3,180
  • Joined: 12-May 09

Re: Attempting to learn Ruby, ran into a problem.

Posted 25 February 2011 - 08:23 AM

Yeah I've been looking into it but haven't been able to figure it out - is the code in your original post the entire program, exactly as you typed it? I did exactly what you said and had no issues running it.
Was This Post Helpful? 0
  • +
  • -

#6 kkslider55  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 19-February 11

Re: Attempting to learn Ruby, ran into a problem.

Posted 25 February 2011 - 12:38 PM

Yeah, that's letter for letter how I typed it. =/I tried re-installing it and I've tried re-typing probably ten million times. I'm thinking maybe it's the computer.

I'll try a different computer, I guess.
Was This Post Helpful? 0
  • +
  • -

#7 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Attempting to learn Ruby, ran into a problem.

Posted 27 February 2011 - 11:26 AM

I ran your code and it works just fine.
Was This Post Helpful? 0
  • +
  • -

#8 T3hC13h  Icon User is offline

  • D.I.C Regular

Reputation: 65
  • View blog
  • Posts: 337
  • Joined: 05-February 08

Re: Attempting to learn Ruby, ran into a problem.

Posted 28 February 2011 - 11:13 AM

Make sure your file is ANSI encoded.
Was This Post Helpful? 1
  • +
  • -

#9 DillonSalsman  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 144
  • Joined: 30-October 07

Re: Attempting to learn Ruby, ran into a problem.

Posted 02 March 2011 - 06:13 PM

I find it confusing that the error message is the parsed line..
Are you running the installer as an administrator if on Vista/7?
Try using interactive Ruby by typing "irb" at the command line.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1