Robert9
(Robert)
24 January 2005 13:50
1
I just installed 1.8.2 to get a feel for Ruby. I tried the hello.rb
file.
This works:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
This does not:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
hello.rb:2: formal argument cannot be an instance variable
It is the same code except the spacing. What is the deal?
Robert
Hi,
hello.rb:2: formal argument cannot be an instance variable
It is the same code except the spacing. What is the deal?
You are probably on Windows, right?
What version of Ruby have you got?
Mine is: ruby 1.9.0 (2005-01-15) [i686-linux]
and I couldn't reproduce this error.
Cheers,
Joao
Both versions worked for me.
Can anyone else duplicate the problem?
- Jamis
···
On 22:50 Mon 24 Jan , sigzero@gmail.com wrote:
I just installed 1.8.2 to get a feel for Ruby. I tried the hello.rb
file.
This works:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
This does not:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
hello.rb:2: formal argument cannot be an instance variable
It is the same code except the spacing. What is the deal?
--
Jamis Buck
jamis_buck@byu.edu
http://jamis.jamisbuck.org
------------------------------
"I am Victor of Borge. You will be assimil-nine-ed."
sigzero@gmail.com wrote:
I just installed 1.8.2 to get a feel for Ruby. I tried the hello.rb
file.
This works:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
This does not:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
hello.rb:2: formal argument cannot be an instance variable
It is the same code except the spacing. What is the deal?
Robert
Hello Robert!
i am on W2K Pro, Ruby:
ruby 1.8.2 (2004-07-29) [i386-mswin32].
Both versions of your code works for me.
Greetings,
Andreas
I just installed 1.8.2 to get a feel for Ruby. I tried the hello.rb
file.
This works:
class Hello
[snip]
This does not:
class Hello
Just a simple test, to avoid unnecessary hairtearing.
It happens me from time to time that due to non-intentionally pressing
some stupid keycombination, a non-printable character finds its way to
my code, and then ruby mystically chokes on it (the terminal doesn't
show any weird upon this).
Then I check my file foo.rb with "ruby -ne 'p $_' foo.rb", and I
immediately see if this is the case.
Csaba
···
On 2005-01-24, sigzero@gmail.com <sigzero@gmail.com> wrote:
Hi,
sigzero@gmail.com <sigzero@gmail.com> writes:
class Hello
attr_reader :msg
def initialize
@msg = "Hello, World"
end
end
h = Hello.new
puts h.msg
print "Press RETURN"
$stdin.gets
hello.rb:2: formal argument cannot be an instance variable
It is the same code except the spacing. What is the deal?
% ruby-1.8.2 -e 'def initialize @msg '
-e:1: formal argument cannot be an instance variable
-e:1: syntax error
Check the line endings.
···
--
eban