Questions tagged [getter]
A getter is a public accessor method, used in object-oriented programming, which returns the value associated with a private member of a class.
1,884
questions
0
votes
1
answer
42
views
How to dynamically set a getter for an Objective-C object property?
FooClass has a property called foo.
It's declared as @property (nullable, nonatomic, readonly, strong) id foo and it has NO underlying storage, it's not synthesized. It's just a getter that by default ...
1
vote
0
answers
52
views
Is it possible to assign return value for getter without private backing field C# [duplicate]
I come across the following example:
public class TimeService
{
public TimeService()
{
Time = DateTime.Now.ToLongTimeString();
}
public string Time { get; }
}
We have ...
0
votes
2
answers
22
views
Quizzler getter requires positional argument
I am doing "The Complete Flutter Development Bootcamp with Dart", and when I am getting the error below:
lib/main.dart:47:42: Error: Too few positional arguments: 1 required, 0 given.
...
0
votes
0
answers
24
views
I'm having trouble using a getter method for an object that has been initialized, but is not in the same class as the getter method
I'm writing a text based game for my computer science class (I'm a beginner and still learning new stuff pretty much everyday) and I'm trying to make a method that will print out the information of ...
1
vote
1
answer
41
views
Pinia getter undefined if used with filter
I have a Pinia store:
import { defineStore } from "pinia";
import { api } from "@/services/api";
export const useMaterialStore = defineStore("material", {
state: () =&...
0
votes
0
answers
34
views
python getter and setter properties
I am new to properties in Python and a bit confused on how below code is working
class FavoriteShape:
def __init__(self, color, shape):
self.color = color
self.shape = shape
@...
0
votes
0
answers
9
views
vue3 app problem to invoke getter from view components
I am trying to invoke from my component view (HomeView) the getter related to the module home (from store) in the way to access the state's variable. Here the files:
//index.js
import { createStore } ...
0
votes
1
answer
69
views
DWScript: Property getter/setter for object
The tdwsUnit declares a property of type TObject, as well as a getter and a setter. An instantiated object shall be stored in an "object store" on the Delphi side. The goal is to transport ...
0
votes
1
answer
39
views
How to importing library that define "favorites" at Flutter
i am very beginner ..and just start learning flutter. I follow "Your First Flutter App" from Google Codelabs, and stop at this step: https://codelabs.developers.google.com/codelabs/flutter-...
0
votes
1
answer
67
views
Const-correctness with getters of vector of non-pointers [duplicate]
I have a quick question regarding const-correctness for getters of vector of non-pointers.
Basically, I have this class with a non-const getter and a const getter for m_Vertices:
class Mesh
{
public:
...
0
votes
0
answers
55
views
IntelliJ seems to not recognize my getter methods
I'm trying to display data from a database in a TableView in JavaFx, and I'm using the class CheckAssunzione for creating my assunzione object that will be used to populate the table. I also have a ...
0
votes
1
answer
25
views
Vuex (Vue3) unable to transmit payload
I have removed the methods that are not involved in the case for a more concise display.
Need to return the count value for the object with the specified id. When I pass a valid id to counter, the ...
3
votes
2
answers
77
views
ValueType as property in class
I am a bit confused with a concept of value types as properties in a class.
As far as I understand, when getter is called - a copy of value type is returned.
Let's have an example:
public struct Point
...
0
votes
2
answers
29
views
How to compute a getter in vue?
I'm expecting to display a computed getter property, but VSC gives me the error "Expected to return a value in 'features' computed property." Even though I'm returnng a true value in getter ...
0
votes
1
answer
18
views
What is the "type" of an ES6 class getter in Typescript?
I have a class that looks like this:
export class WidgetsManager {
private foo?: boolean;
private bar?: boolean;
// ... and so on
constructor(config: Config | null) {
this.foo = config....
0
votes
0
answers
26
views
String getMode() and setMode(String mode), or String mode() and mode(String mode)? Is the way of naming getters/setters changing, and when? [duplicate]
Up until today, I created my objects with getters/setters of the form:
private String mode;
public String getMode() { return this.mode; }
public void setMode(String mode) { this.mode = mode; }
But ...
0
votes
0
answers
6
views
Why is a `.get()` needed to access the headers of a Request object?
I want to get the value of a Header ( 'X-Forwarded-Host' ) from a Request object and I realized the only way for me to get it is
const forwardedHost = context?.request?.headers.get("x-forwarded-...
0
votes
2
answers
3k
views
The getter 'params' isn't defined for the type "GoRouterState" Flutter
I am trying to resolve the issue with getter, error message:
The getter 'params' isn't defined for the type 'GoRouterState'.
Try importing the library that defines 'params', correcting the name to ...
0
votes
0
answers
25
views
What is the difference between these two ways to get info in OOP in dart flutter? [duplicate]
What is the difference between these two ways to get info in OOP in dart flutter?
int get age {
return vehicleAge;
}
int age() {
return vehicleAge;
}
I undestand that the fisrt one is called ...
0
votes
0
answers
60
views
Why does the entity's getter get called twice?
I use Spring Boot with Hibernate. I have an entity containing some credentials:
@Entity
class MyEntity {
@Column(name = "credentials", columnDefinition = "jsonb")
@Type(...
1
vote
1
answer
103
views
Ember Octane, Tracked property not recomputing get function using the property
In emberJS Octane, I expect a "get" function to be recomputed when the used tracked properties inside of it changes. It does not in my case.
Here is my template :
{{#each this.model....
0
votes
1
answer
42
views
How to pass an input event to the getter store Vuex?
How to pass an input field to the getter?
I'm trying to pass th einput field to the getter as a paramether. How to pass the param to the getter ?
<input
type="text"
...
0
votes
0
answers
30
views
c:forEach calls its getter for each p:remoteCommand [duplicate]
I do have an JEE application with JSF. As soon as I do use the c:forEach element, then the backend call for detecting the items is called with each p:remoteCommand, talking to the backend, even if no ...
0
votes
0
answers
14
views
Accessing getter for an object that is part of a vector contained in separate class
I'm trying to figure out how to use a getter function with a particular object that is contained within a vector that is in a separate class. Ok, there's a class Patron that contains GetNumBooks(), ...
-1
votes
1
answer
116
views
Converting a Javascript Object to Lua table
I have a Javascript object where one of the keys is a getter and I want to convert the entire object to a Lua table in order to use it in a wiki module.
So far I have managed to find how to convert ...
0
votes
1
answer
161
views
How can I pass back a function/method variable?
If I want to create a getter accessor for a method variable, the getter does not give back the variable, but it executes the code referenced by the variable.
unit Unit5;
interface
uses
Winapi....
1
vote
1
answer
58
views
What is the difference between a function and getter in Dart?
To get a value from a function I can to this:
bool goOutside() {
if(today is a good day){
return true;
}else{
return false;
}
}
But I can also do this:
bool get goOutside {
...
1
vote
0
answers
30
views
Python property getters and setters not working [duplicate]
I am attempting to use property-based getters and setters in Python and am getting strange problems. Consider the following code:#!/usr/bin/env python
class anyThing(object):
def __init__(self):
...
2
votes
1
answer
175
views
Config.GetSection<T> with invalid class property names
Using IConfigurationRoot extension method
public static T GetSectionAsObject<T>(this IConfigurationRoot configuration, string key)
{
return configuration.GetSection(key).Get<T>();
}
I ...
-1
votes
2
answers
75
views
Why doesn't return getter like in Java (C#)
I want to move from Java to C# and I want to try getter and setter like in Java
internal class Person
{
internal string name;
internal void setName (string name)
...
-2
votes
1
answer
40
views
How to access text value outside of initialization of Radiobutton
fruit_frame = LabelFrame(root, text = "Fruit", padx = 15, pady = 15) fruit_frame.grid(row = 0, column = 0)
veg_frame = LabelFrame(root, text = "Vegetables", padx = 15, pady = 15) ...
0
votes
0
answers
54
views
Getter returning incorrect value
I'm building an application for storing/searching/sorting cars and I'm running into an issue with one method.
I have six ArrayLists, storing variables of different data types:
Car c1 = new Car(1, &...
0
votes
1
answer
93
views
Swift Crash in getter for location services
I received several crashes in Xcode organizer, but I'm not able to find the root cause for it. Would be nice, if someone could look at it and give his thoughts ...
... here is the code of the getter
/...
0
votes
2
answers
195
views
c++ setter/getter does not work as expected
for some reason my prof insists I have to use setter/getter everywhere.
Well... in this linked list I don't understand why this one doesn't work
#include <iostream>
#include <string>
using ...
1
vote
0
answers
72
views
why my getter property is directly in my class instance?
I was testing a getter in my class and I faced a contrast in my implementation and document, based on MDN document a class getter property should be defined inside the instance's prototype
Getter ...
-2
votes
1
answer
82
views
Pinia : state change by It self [duplicate]
G'day,
I would like to have 3 elements :
Current Date (to display current month)
current date less 1 month (to display the month before)
current date plus 1 month (to display the next month)
I ...
0
votes
1
answer
146
views
How to use the non-const getter if there's a const one too?
If I have a class with getters of return type both const and non-const, how can I use the non-const one?
The class (MeshManipulator.h):
namespace vortex::meshSculptEngine
{
class MeshManipulator
...
0
votes
1
answer
84
views
getter setter can't change textBox.Text control value in Winform c#
Why textBox3.text do not shows value _TextBoxRequestMsg. MessageBox opens and shows _TextBoxRequestMsg value OK, console prints too.
public partial class F_Main : Form
{
private string ...
-2
votes
2
answers
67
views
How can I resolve "The argument type '
The getter 'message' isn't defined for the type 'Object'.
Try importing the library that defines 'message', correcting the name to the name of an existing getter, or defining a getter or field named '...
0
votes
2
answers
149
views
How do getters work in nested objects when getting a property name from a nested object during object construction?
I want to get a nested property name in an object during object construction.
What am I doing wrong? How do I get the expected output: 'c' from the nested object?
Starting point: MDN documentation
...
0
votes
3
answers
48
views
Using object in another class
I want to use inst in another class SubscribeTables() I need it with all of its data. I tried to make a getter in Main() but it didnt work. Maybe i can pass it to another class somehow? Can someone ...
0
votes
0
answers
56
views
Adding a Command Within C# Get/Set Shorthand
Here is my understanding of C# get/set shorthand. The long way of defining a property in C#:
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
We can ...
0
votes
0
answers
53
views
Is it improper to use a getter in a for each loop? Java
Is it improper to or not to use a getter in a for-each loop. (I'm new to this)
Example for reference
public static void main(String[] args) {
ArrayList<Program> programs = new ...
1
vote
1
answer
115
views
dotnetbrowser javascript interacting with c# this[string name]
I have a project that i am running .NET code inside. i need to use the existing objects and cannot modify them.
The class in c# that i am trying to use is
class Fields
{
Hashtable list = new ...
4
votes
1
answer
181
views
How do getters and setters work in Python?
The following is a snippet of code from CS50P.
I don't understand how it works and cannot seem to find an adequate explanation.
Firstly, as soon as the Student constructor is called with user inputted ...
1
vote
1
answer
116
views
Javascript: is there "Symbol.iterator" analogue for the object spread syntax - { ...obj }?
There is a well known symbol: Symbol.iterator, that, when defined as a generator function property on an object, allows the object to be used in a [...object] syntax. So, you can do, eg., this:
const ...
1
vote
1
answer
803
views
Access current route inside a getter in Pinia?
I would like to know what is the current route so that I can compute the size of the sidebar.
import { defineStore } from 'pinia'
export const useSidebarStore = defineStore('sidebar', {
state: () =&...
1
vote
0
answers
23
views
How to transform any column while fetching models
I am using adonisjs 5 for my project to create REST APIs. I am fetching records from Employees table. But what I want want to do is to format dob column to YYYY-MM-DD when retrieving the data.
I am ...
0
votes
1
answer
378
views
problem defining class property in python
I'm new to python programming, I'm trying to encapsulate all property checking of a size in the class object below but one of them is not working (checking to see if withdraw is bigger than amount of ...
0
votes
1
answer
346
views
Wanting to change a setter of a single input field, how to advance to check if those were changed before and how not to lose the previous addages?
This is a follow up question to Setter for HTMLInputElement.value.
If I changed the setter and getter of a single input-element (not on all input elements in general), and later on I want to make ...