class-instance-variables Questions

8

Solved

I read When do Ruby instance variables get set? but I'm of two minds when to use class instance variables. Class variables are shared by all objects of a class, Instance variables belong to one obj...

2

Solved

According to Reek, creating a class variable is considered a 'code smell'. What is the explanation behind this?
Sherrill asked 26/11, 2016 at 13:55

3

Solved

Can anyone tell me about the difference between class variables and class instance variables?
Unijugate asked 27/9, 2010 at 9:32

3

I have created some Python classes to use as multivariate data structures, which are then used for various tasks. In some instances, I like to populate the classes with various value sets. The defa...
Michaelson asked 9/11, 2015 at 17:57

4

Solved

Here is the link to my first question: Creating class instance from dictionary? So I am trying to create class instance from dictionary which holds keys that class has not. For example: class MyCl...
Sandalwood asked 8/5, 2015 at 16:47

3

my idea is to create a community wiki for people that come from a java background because reading a lot of explanations, I couldn't comprehend anything until I actually tried a couple of things and...
Prudence asked 29/7, 2014 at 21:23

2

Solved

I know that some say that class variables (e.g. @@class_var) should be avoid in Ruby and should use the an instance variable (e.g. @instance_var) in the class scope instead: def MyClass @@foo = '...
Unrounded asked 24/9, 2010 at 12:44

4

Solved

If I have the following piece of Ruby code: class Blah def self.bleh @blih = "Hello" @@bloh = "World" end end What exactly are @blih and @@bloh? @blih is an instance variable in the class Bl...
Polarity asked 8/4, 2010 at 9:34

2

If I have a class with an attr_accessor, it defaults to creating an instance variable along with the corresponding getters and setters. But instead of creating an instance variable, is there a way ...

3

Solved

class << self attr_accessor :n, :totalX, :totalY end The syntax above is used for defining class instance variables. But when I think about what syntax implies, it doesn't make any sense to...
1

© 2022 - 2024 — McMap. All rights reserved.