self Questions

2

Solved

Why is the 'self'-call to a non-satic method in this example working? class A{ protected function aNonStaticMethod(){ return __class__; } public function aEcho(){ echo self::aNonStaticMetho...
Parget asked 7/10, 2013 at 6:18

1

Solved

I try figure out why self point to the GameViewController instead of Answer GameViewController.swift class GameViewController: UIViewController { var gameplay = QuestionsController(colors: color...
Ofori asked 25/2, 2016 at 19:55

2

Yesterday I reviewed a piece of code in Swift which included this line: self.self.someProperty Which surprised me, because the word self is reserved and used as a reference to the current instance...
Rhodium asked 28/12, 2015 at 19:58

3

Solved

I'm reading through Mark Dalrymple's Learn Objective-C on the Mac (only at the chapter on Protocols, so still relatively newbish) and trying to figure something out: Why would you ever reference a...
Guib asked 24/8, 2010 at 18:30

5

Solved

I've never seen code like this: public static function getInstance() { if ( ! isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; } Is it the same as new cla...
Towner asked 7/3, 2010 at 13:36

1

Solved

I'm getting terribly confused by the colon notation used when defining/calling Lua functions. I thought I'd got my head round it until I saw this piece of code: function string.PatternSafe( str )...
Ladawnladd asked 18/8, 2015 at 19:23

3

Could anyone please help me to understand the difference between "yield self" and "yield"? class YieldFirstLast attr_accessor :first, :last def initialize(first = nil, last = nil) @first = fir...
Mcdonnell asked 20/8, 2012 at 4:30

1

Solved

I don't understand the 7,8,9 line: var worker = new Worker('doWork.js'); worker.addEventListener('message', function(e) { console.log('Worker said: ', e.data); // Here it send's the data. }, fal...
Fabio asked 9/6, 2015 at 14:54

2

In XCode 6.2, I have a Swift project where a main-object ("Backbone") creates sub-objects with pointers back to Backbone: class Backbone { let logManager: QCLogManager! let cloudJobManager: Clou...
Phenolphthalein asked 21/4, 2015 at 1:20

2

i'm refactoring code in order to add object orientation and am just testing the code. pattern = r"((([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])[ (\[]?(\.|dot)[ )\]]?){3}([01]?[0-9]?[0-9]|2[0-4][0-9]|25...
Satterwhite asked 11/4, 2015 at 10:47

1

I can create an object with four properties like this $pocketKnife = New-Object PSObject -property @{ Color = 'Black' Weight = '55' Manufacturer = 'Buck' Blades = '1' } And is works basicall...
Veneaux asked 14/2, 2015 at 14:30

1

I have a simple class that inherits from the NumPy n-dimensional array. I want to have two methods of the class that can change the array values of an instance of the class. One of the methods shou...
Elysian asked 12/1, 2015 at 20:14

1

I segue to a Viewcontroller that immediately has 0 objects for "self" and although I can access "self." objects, I cannot see them in the debug window. Without pasting the code, is there a known re...
Excel asked 21/11, 2014 at 15:43

1

In this StackOverflow question I learned that self:: was not inheritance-aware where static:: was (in PHP). When it comes to defining a bunch of constants within a class, if you want to override th...
Falsecard asked 5/11, 2014 at 15:2

1

Solved

I noticed that initializing a property in a Swift initializer works using both: self.property = 1 and property = 1 Is there any difference between the two? If not, is there a convention that ...
Wini asked 29/9, 2014 at 11:57

2

How come I'm allowed to change "self" this way: self.map! {|x| x*2} Or this way: self.replace(self.map {|x| x*2}) But not this way: self = self.map {|x| x*2} Why doesn't Ruby allow me to c...
Schiff asked 14/9, 2014 at 14:42

3

Solved

I have started learning python classes some time ago, and there is something that I do not understand when it comes to usage of self.variables inside of a class. I googled, but couldn't find the an...
Aynat asked 29/8, 2014 at 1:46

1

Solved

class MyClass def test puts my_id puts self.my_id end private def my_id 115 end end m = MyClass.new m.test This script results in an output: 115 priv.rb:4:in `test': private method `m...
Purtenance asked 22/8, 2014 at 13:22

2

Solved

I have a Swift class that has a constant ivar (are they called instance constants now?). To set the value to this constant, I need to call an initializer of the desired object and pass itself. Howe...
Alvera asked 14/6, 2014 at 9:38

1

I have a problem in class inheritance in Python; maybe it's not related to inheritance, but I have no other idea. I'm working with selenium web-driver. Here's the code I use: from selenium import ...
Selfexecuting asked 20/5, 2014 at 6:44

5

I have a problem with the below macro which i use to log various bits of information #define JELogVerbose(fmt, ...) DDLogVerbose((@"%@ %@ - " fmt), NSStringFromClass([self class]), NSStringFromS...
Ezmeralda asked 29/4, 2014 at 16:57

2

Solved

See this example for a demonstration: >>> class M: def __init__(self): self.x = 4 >>> sample = M() >>> def test(self): print(self.x) >>> sample.test = test &g...
Pascia asked 15/4, 2014 at 2:36

2

Okay. So I saw someone using this code, and I understand it, I so I'm going to use it. Is it necessary to have __init__? class A(object): def __init__(self): self.x = 'Hello' def method...
Vidar asked 24/3, 2014 at 4:43

1

Solved

I am currently studying the sample code provided by Apple for Sketch and I stumbled upon some syntax that I haven't seen before. It's in SKTGraphicView.m in the function moveSelectedGraphicsWithEv...
Epitasis asked 21/3, 2014 at 17:36

1

Solved

When I have an Objective C instance create a block that needs to refer to the instance, I frequently do so through a weak pointer that won't keep the instance alive and produce a retain cycle, like...
Urolith asked 19/3, 2014 at 16:1

© 2022 - 2024 — McMap. All rights reserved.