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
2
votes
1 answer

Nested class to access other nested class' property

I'm looking for a MATLAB solution in which a nested subclass can access the properties of another nested subclass. In the following example the superclass has two properties which each are initialised as two different subclasses: classdef…
Johannes
  • 135
  • 5
2
votes
0 answers

React Class properties not building with Webpack and Babel

I am trying to tidy some React code by using a static property of the class something like class X extends React.Component { static counter = 0 ... render() { return(
{X.counter}
) } } The build fails with unexpected…
avrono
  • 1,648
  • 3
  • 19
  • 40
2
votes
1 answer

Why PHP is not forbidding me from initializing class properties using heredoc syntax?

I'm using PHP 7.1.11 As mentioned in the PHP manual : Heredocs can not be used for initializing class properties. Since PHP 5.3, this limitation is valid only for heredocs containing variables. The above sentence is saying that class properties…
PHPLover
  • 1
  • 51
  • 158
  • 311
1
vote
1 answer

Referring to other class properties in comprehension

Say I define some class property based on another: class X: foo = 42 bar = foo + 5 # X.bar == 47 this works fine. However, foo is not available if I use a list (or dict, etc.) comprehension: class X: foo = 42 bar = [foo + i for i…
1
vote
0 answers

Why each new property, dynamically added to an existing class, overwrites previously added ones?

I am creating a Python class with a very long list of properties. To avoid boilerplate, I want to define a minimalistic class, and then extend it with my custom properties, which names are provided as a list. However, when I create and add…
R Kiselev
  • 1,124
  • 1
  • 9
  • 18
1
vote
2 answers

Accumulate strings and array values into an array as a class property via method

I have a class with method add() that accepts strings and arrays. I need to have an array with all users, but I cannot seem to get it. All I get is multiple arrays with all users. How could I merge those arrays into one? class Users { function…
1
vote
2 answers

How to set the size validator of a class property to a known constant

I would like to do something like the following code where all 3 properties are statically known to be size (1,10) without having to explicitly re-write the 10 at the property declaration. classdef Example properties(Constant) …
1
vote
2 answers

How to update value of a class property in C#?

How can I increment the value of the property TeamSize each time a new Athlete object is added? Because I cannot create a variable to store the value for TeamSize and increment that value each time a new Athlete object so I wonder if there is…
user15343916
1
vote
3 answers

How to get the name property of the active NamedSheetView class?

Excel now has the possibility to store personal filtering views to help collaboration in simultaniously used documents. I could only find Microsoft documentation for an add-in, but the function is available in my Excel version of MS Excel for…
LegrA
  • 41
  • 4
1
vote
0 answers

Support for the experimental syntax 'class-Properties' isn't currently enabled even after adding plugins

This is my app.js file: import React from "react"; const WhatsAppWeb = require("baileys"); //Only this line causing an error function App() { return

Hello

; } export default App; Here is my package.json file: { "name": "version4", …
Amin
  • 21
  • 1
  • 5
1
vote
2 answers

How to make a interface base property, then implement with the derived?

I am creating a chat app. In the chat, users can send three types of messages: images, files, and text messages. I am trying to create an interface called IMessege that contain 3 class properties: interface IMessege { object content {…
avivgood2
  • 227
  • 3
  • 19
1
vote
1 answer

Variant of toEqual that works with class properties in the same way that it works with class methods

This is the scenario. The first class has a method getName, and the second class has a class property getName. The first class works with toEqual, and the second class does not. class Person01 { constructor(name) { this.name = name; } …
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
1
vote
0 answers

class property list in swift

I've got a class: public class Circle: Shape { public var radius: Double = 0.0 public var diameter: Double { get { return 2 * radius } set { radius = newValue / 2 } } public var area: Double { …
1
vote
1 answer

Objective-C class property in category causes warning

In Xcode 8.3.2 and Objective-C, if you have a class property in a category, it sometimes causes a warning. How can I get rid of it? The warning is ld: warning: Some object files have incompatible Objective-C category definitions. Some category…
Clay Bridges
  • 11,602
  • 10
  • 68
  • 118
1
vote
0 answers

php update static property array

Hello I had defined an array as static property in parent In the child the same array is needed but i need another value in this array I redefine the array and override the parent's array The question: Is there another way to add new value in the…
Mustafa Agamey
  • 513
  • 2
  • 9
  • 21