Unable to access instance variable outside the class in ruby -


outside of class p @stack in my code while trying to print, and it < By inserting code> zero and entering attr_accessor: stacks,: each_stack_size,: stack_number . As always, it works fine and shows data while using the inside of the class. What am I missing?

class setOfStacks attr_accessor: stack, every_stack_size ,: stack_number # To begin the hash and hold the initial stack to capture all the stacks. Def start = stacks = Hash.new # To capture all the stacks to catch all the stacks, set the size of each stack @ hach_stack_size = 3 # @ stack_number = 1 # Current stack number @stacks [@stack_number] = Array .new end ... ... end @obj = SetOfStacks.new @ obj.push (4) @OzagePash (5) @OzagePash (6) @OzagePash (7) @objpopp @ stex

To print a frequency variable, you must access it by reference of frequency.

  p @ obj.stacks    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -