Beginner to Ruby

A

Abhilash Nama

Hi,

I am trying to learn to program using Ruby and I have downloaded the
Ruby 1.93 installer. My first code is here: http://codepad.org/KlBucAPF
but, this doesn't seem to work when I put it in Interactive Ruby on my
computer.

I would appreciate if someone could help me figure out why?

Thanks!

Best,
Abhilash.
 
M

Marvin Gülker

Hi,
Hi,

I am trying to learn to program using Ruby and I have downloaded the
Ruby 1.93 installer. My first code is here: http://codepad.org/KlBucAPF
but, this doesn't seem to work when I put it in Interactive Ruby on my
computer.

"Doesn't work" is quite vague. Can you be more precise, e.g. by posting
the whole error message you experience?
I would appreciate if someone could help me figure out why?

Thanks!

Best,
Abhilash.

Vale,
Marvin
 
S

Simon Krahnke

* Marvin Gülker said:
"Doesn't work" is quite vague. Can you be more precise, e.g. by posting
the whole error message you experience?

It works just fine here, I don't see any see any reason why it shouldn't.

,----
| $ irb raw.rb
| raw.rb(main):001:0> class Person
| raw.rb(main):002:1> attr_accessor :name, :gender, :age
| raw.rb(main):003:1> end
| => nil
| raw.rb(main):004:0>
| raw.rb(main):005:0* person1 = Person.new
| => #<Person:0x7ff067f626b0>
| raw.rb(main):006:0> person1.name = "Abhilash Nama"
| => "Abhilash Nama"
| raw.rb(main):007:0> person1.gender = "Male"
| => "Male"
| raw.rb(main):008:0> person1.age = "30"
| => "30"
| raw.rb(main):009:0>
| raw.rb(main):010:0* puts person1.ageraw.rb(main):010:0* raw.rb(main):010:0> 30
| => nil
`----

Using puts in an irb session seems to mess up the output some. But it says 30 on the end the line.

Using ruby, not irb, it just says "30".

mfg, simon .... l
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,828
Messages
2,569,736
Members
45,518
Latest member
vlonesshirt

Latest Threads

Top