What do you call this part of an object? @action== positions=0,0
elements="\n","\n". Thanks in advance.
My Object
[#<Diff::LCS::ContextChange:24251690 @action== positions=0,0
elements="\n","\n">
···
--
Posted via http://www.ruby-forum.com/.
What do you call this part of an object? @action== positions=0,0
elements="\n","\n". Thanks in advance.
My Object
[#<Diff::LCS::ContextChange:24251690 @action== positions=0,0
elements="\n","\n">
--
Posted via http://www.ruby-forum.com/.
Mmcolli00 Mom wrote:
What do you call this part of an object? @action== positions=0,0
elements="\n","\n". Thanks in advance.
They are instance variables.
class Foo
attr_accessor :x, :y
def initialize(x,y)
@x = x
@y = y
end
def say_something
puts "@x is #{@x} and @y is #{@y}"
end
end
f = Foo.new("hello", "world")
puts f.inspect
f.say_something
# Using the accessor methods which attr_accessor adds
f.x = "goodbye"
puts f.x
puts f.y
You really need to understand instance variables, classes and methods if
you are going to start programming in Ruby. I suggest you start here:
http://www.ruby-doc.org/docs/ProgrammingRuby/
(If you want a paper or PDF book, there are newer versions of this book
available from www.pragprog.com)
--
Posted via http://www.ruby-forum.com/\.
Thanks Brian.
--
Posted via http://www.ruby-forum.com/.