Questions tagged [class-properties]

A class property, in some object-oriented programming languages, is a particular type of property that applies to a class rather than an instance of the class.

Class Property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method.

Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls.

See: - Properties (tag)

49 questions
11
votes
3 answers

Iterable property

I have a library (django-piston) which is expecting some parameters of the class as class properties. I would like to define this value dynamically in a method. So I wanted to do something like: class MyHandler(BaseHandler): @property def…
Mitar
  • 6,756
  • 5
  • 54
  • 86
7
votes
2 answers

Does `nonatomic` makes sense in a `readonly` declared property (including class property)?

EDIT: This question applies to normal declared properties as well (not only to class properties)! Original Post: Lets say I have the public class method sharedInstance which is currently implemented as a getter method: @interface MyClass +…
Buju
  • 1,546
  • 3
  • 16
  • 27
5
votes
3 answers

Using Arrow function for class properties in React. Not clear

I came across the arrow function feature being used as Class property in React component. Looking online I found that it makes code more readable and because of the arrow function features we do not have to bind the handlEvents function inside of…
Haris Khan
  • 389
  • 1
  • 2
  • 12
5
votes
3 answers

How to create an abstract class attribute (potentially read-only)

I have spent a lot of time researching this, but none of the answers seem to work how I would like. I have an abstract class with a class attribute I want each subclass to be forced to implement class AbstractFoo(): forceThis = 0 So that when I…
Pro Q
  • 4,391
  • 4
  • 43
  • 92
4
votes
2 answers

ES6+ / React Native class properties: The first one is undefined

I'm trying to use the panResonder in my React Native app. I tried doing so using class properties instead of constructor and super(). Here is the code: export default class Deck extends Component { panResponder = PanResonder.create({ …
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
3
votes
3 answers

Use recursion to accumulate rows without depending on class property variable

Having this array : [ "id" => 5, "name" => "Item 5", "all_parents" => [ "id" => 4, "name" => "Item 4", "all_parents" => [ "id" => 3, "name" => "Item 3", "all_parents" => [ …
3
votes
2 answers

How to execute a function before and after each class method call?

I want to insert on pre execute and post execute hooks on functions in javascript classes. Lets say I have a class like this. class Foo { method1(p1, p2) { this.p1 = p1; this.p2 = p2; } method2(p3) { this.p3 = p3; } } I want to…
Souradeep Nanda
  • 3,116
  • 2
  • 30
  • 44
3
votes
1 answer

Uninitialized TypeScript class properties are not iterated

I have the following class: export class SomeModel { prop1: number; prop2: number; comment: string; } and the following method to dynamically get its properties: getTypeProperties(obj: T): string[] { const ret: string[] = []; for…
3
votes
1 answer

Macro to detect availability of class properties in Objective-C

Xcode 8 introduces Objective-C class properties and I would like to add one to an Objective-C library. However I would like the library to still compile with Xcode 7. Is there an availability check I can do at compile time? Something like #if…
Frank Schmitt
  • 25,648
  • 10
  • 58
  • 70
3
votes
2 answers

VBA Compile Error: Can't Assign to Read-Only Property Returning Array from Custom Class Get Property

I'm having an issue with the Get property from a custom class in VBA (Excel 2010). If an index argument is not given, then my Get property should return a reference (at least that's my impression) to the Class' array. If an index is given, it should…
Bryan Harper
  • 55
  • 2
  • 8
2
votes
1 answer

What is the purpose of the "@" symbol in Javascript classes?

In this example on AdonisJS, the Post class definition includes @column sections. Can someone explain what this does? I assume it's creating multiple instances of the 'column' class within the Post class as member variables, each instance having a…
Ryan Griggs
  • 2,457
  • 2
  • 35
  • 58
2
votes
2 answers

Best practice for defining a class that computes attributes in order when initialized

I would like to define a class that does something like: Class computer(): def __init__(self, x): # compute first the 'helper' properties self.prop1 = self.compute_prop1(x) self.prop2 = self.compute_prop2(x) #…
Lilianna
  • 337
  • 3
  • 12
2
votes
2 answers

How to input-check a class property

I have a certain class MyClass with a class attribute SOMETHING: class MyClass(object): SOMETHING = 12 I would like SOMETHING to be enforced to meet a certain condition, e.g. SOMETHING < 100. How could I do that? Ultimately, this class is meant…
norok2
  • 25,683
  • 4
  • 73
  • 99
2
votes
1 answer

Call method from method inside same class

I am trying to create a flow structure in an object that is based on a class. I have 4 methods (where 3 methods should be called from the method [run()]. Question: Should you be able to call a method from another method assuming you are in the same…
Toolbox
  • 2,333
  • 12
  • 26
2
votes
1 answer

Displaying non readable DB data into readable format

I have a table that contains a field that only has numbers. What I'm trying to achieve is to represent the actual numbers within an enum and "translate" the numbers into values that is readable. For example, I have a User table with a field called…
1
2 3 4