Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
121 views

How can I define a variable that has shared access by instance methods of a Struct? I can use a global variable $tmp like this: Triple = Struct.new :x, :y, :z do def mul s $tmp.x = x * s $...
igouy's user avatar
  • 2,700
0 votes
1 answer
99 views

it might be a silly question since I'm new to Python. However, I hope someone can explain this because I try to find lots of resource but still hardly understand the mechanism behind. So I create a ...
Phuc Dee's user avatar
0 votes
3 answers
1k views

I have sample class and instances: class A: def __init__(self, num) #instances a = A(2) b = A(4) c = A(5) d = A(7) In another class (class B) within a method, I have to get the highest value ...
chilliyayi's user avatar
-1 votes
3 answers
3k views

I don't understand how to get the value of a field instance from python class. I added what I need this code to do in get_person method. The output should be 3 or None. class Digit: def __init__(...
user17625175's user avatar
0 votes
1 answer
308 views

This is my code: class Category(): def __init__(self,category,balance=0,ledger=[]): self.category = category self.balance = balance self.ledger = ledger def ...
Emeric FOKOUONG TOUOLAC's user avatar
0 votes
3 answers
3k views

Sorry for the basic question but I'm learning, new to programming. I am trying to call a method that is in another class but I'm unable to without passing in the required values for the constructor of ...
Charlotte O'Regan's user avatar
1 vote
1 answer
533 views

I am learning Ruby and have stumbled upon some code similar to the one below, which shows the difference between instance variables and class instance variables. I've tested it in my console and it ...
wawa's user avatar
  • 11
0 votes
2 answers
303 views

I have this parent class: class ListBase @@list = [] def self.list @@list end end I'm trying to create two child classes like so: class Child1 < ListBase end class Child2 < ...
Ashish Acharya's user avatar
0 votes
0 answers
117 views

I have following abstraction in my code: class A{}; class B: public A{}; class C: public B{}; Now when I declare an instance of class C every thing is OK. The problem is when I declare class C in a ...
Kawsar Haghshenas's user avatar
0 votes
1 answer
196 views

I read in Sebesta that static bound methods do not need to be stored in the CIR but i cant figure out why. If it is not stored in the CIR, how does the compiler know which statically bound method is ...
Gagan Ganapathy's user avatar
0 votes
2 answers
213 views

I have a DateTime class instance variable @current_year = DateTime.now.year, which I have set into a footer partial. This partial is rendered across several of my clientside pages (and across multiple ...
Boucherie's user avatar
  • 543
1 vote
1 answer
64 views

Ok, so I've read up on class variables, class instance variables and instance variables in Ruby. I found this explanation by Phrogz very illuminating. Now I'm trying to add a variable to my class ...
megahra's user avatar
  • 335
0 votes
1 answer
40 views

I'm trying to create a chemistry GUI that shows various information about each element. I'm using a list of class instances to print out the information, but I continue to get a 'list' object has no ...
user avatar
0 votes
1 answer
154 views

I want to leverage class methods on child classes in ruby, but those that rely on child instance variables are not working. I was told "don't use class variables! (@@)", so I'm not. How can I make ...
skaz's user avatar
  • 22.8k
0 votes
2 answers
4k views

How do you access an instance in an object and pass it to another 'main' object? I'm working with a parser for a file that parses different tags, INDI(individual), BIRT(event), FAMS(spouse), FAMC(...
user avatar
0 votes
1 answer
701 views

I have a Python project (I'm quite new to Python), and on one of the webpages, there is a drop-down box which should display a list of all of the projects whose 'status' fields are set to 'live'. It ...
Noble-Surfer's user avatar
  • 3,192
1 vote
2 answers
1k views

Hello I have a simple WPF window and I want to load and display a logo image on specific "Image" item. The following code works perfectly and I can display the logo. namespace WPFexample { public ...
Spyros's user avatar
  • 261
-1 votes
1 answer
617 views

I assigned a class instance variable as an array. class Red @items = ["brinjal", "banana"] puts @items.inspect def test puts @items.inspect end end p = Red.new # => prints ["brinjal",...
Subbi reddy dwarampudi's user avatar
4 votes
4 answers
4k views

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 ...
Demyanov's user avatar
  • 921
0 votes
2 answers
85 views

How is using studentName and studentAverage different in the class or in the constructor? public class StackOverFlowQ { String studentName; int studentAverage; public void ...
Snur Hamid's user avatar
5 votes
3 answers
4k views

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 ...
akostadinov's user avatar
1 vote
1 answer
195 views

I need a class variable which does not get inherited, so I decided to use a class instance variable. Currently I have this code: class A def self.symbols history_symbols end private def ...
Alexander Popov's user avatar
3 votes
4 answers
662 views

I would like to deny creating instance variables in Ruby,to prevent unattended variables being created 'by mistake'. My class: class Test def initialize @a = 'Var A' end def make_new @...
meso_2600's user avatar
  • 2,146
0 votes
1 answer
73 views

is there any work around to access the parents values that ware overwritten by child? parent::$prop: expect to be static. and the same with: self::$prop class base { public $name = 'base'; ...
learning php's user avatar
  • 1,274
1 vote
4 answers
292 views

I am doing the ruby koans and I am on the DiceSet project. I've made the DiceSet class but my instance variables don't seem to persist with the instance like I thought they would. My code is class ...
Alexander Burke's user avatar