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">
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">
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
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)
Thanks Brian.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs