0
votes
3answers
31 views

Class attribute losing value after initialize ends

Can someone please help me understand why the class attribute is losing the value outside the initialize method? 2.0.0-p0 :031 > $arr = [1, 2, 3, 4] => [1, 2, 3, 4] 2.0.0-p0 :032 > class ...
2
votes
4answers
68 views

What are the downsides to declaring “instance” variables at the class scope in Ruby?

I almost never see this in Ruby code, but it seems to be valid: class Foo @bar = "bar" def self.print_bar puts @bar end end My interpretation of the above that @bar is an instance ...
4
votes
3answers
721 views

Inherit class-level instance variables in Ruby?

I want a child class to inherit a class-level instance variable from its parent, but I can't seem to figure it out. Basically I'm looking for functionality like this: class Alpha ...
2
votes
2answers
1k views

Same instance variable for all actions of a controller

I have a rails controller with two actions defined : index and show. I have an instance variable defined in index action. The code is something like below: def index @some_instance_variable = foo end ...
0
votes
1answer
561 views

how to reference (sub)components in Sencha Touch after a initial setup?

I'm trying to create a webapp with sencha. I've already tweaked a lot of examples and the framework is startiong to make sense to me. There are two major things I keep bumping into though. 1. ...
2
votes
4answers
126 views

What kind of Ruby variable do I want to use here?

I’m still learning Ruby, and I’m curious about whether it is appropriate to use a class variable, constant, or local variable in this scenario. In my below code example (that generates random ...
4
votes
2answers
1k views

Android Static Variable Scope and Lifetime

I have an application that has a Service that uses an ArrayList<Double> to store numbers in the background for a very long time; the variable is initialized when the service started. The ...
2
votes
6answers
3k views

Why is everything a property in iOS SDK tutorials?

In most of the iOS SDK tutorials I've read online both from Apple and elsewhere, so many instance variables are made properties, even when they are only accessed from within their own class. E.G. in ...
2
votes
3answers
349 views

JavaScript OOPS Question

A JavaScript newbie here. I have this following code: function testObject(elem) { this.test = "hi"; this.val = elem; console.log(this.test+this.val); echo(); function echo () { ...
6
votes
2answers
6k views

Why do my controller's instance variables not work in views (Rails)

I would like to add a couple of instance variables to my controller, since the variables in question are required from within more than one action's view. However, the below example does not work as I ...
7
votes
3answers
825 views

Have you ever used a “class instance variable” in any of your Ruby code?

I can understand why you would need a class variable to keep track of things like the total number of objects that have been instantiated in that class. And I can understand why you would need an ...