Complete the code to define a class instance variable in Ruby.
class MyClass [1] = 10 end
Class instance variables start with a single @ inside the class body but outside any method.
Complete the code to access a class instance variable inside a class method.
class MyClass @count = 5 def self.get_count [1] end end
Inside a class method, you can access class instance variables directly with @variable.
Fix the error in the code to correctly initialize and access a class instance variable.
class MyClass [1] = 0 def self.get_value @value end end
To initialize a class instance variable, assign it with '@value' inside the class body or class methods, not inside instance methods like initialize.
Fill both blanks to create a class instance variable and a class method that returns it.
class MyClass [1] = 100 def self.get_value [2] end end
Class instance variables use a single '@' and can be accessed inside class methods with '@variable'.
Fill all three blanks to define a class instance variable, a class method to set it, and a class method to get it.
class MyClass [1] = nil def self.set_value(val) [2] = val end def self.get_value [3] end end
Class instance variables use '@value'. You can set and get them inside class methods using '@value'.