Questions tagged [objectinstantiation]
92 questions
4
votes
2 answers
Filling out Object Properties with default values Recursive
I want to populate the object's properties with some dummy data. Here is my code but it always returns null.
private static object InsertDummyValues(object obj)
{
if (obj != null)
{
var properties =…
user186635
3
votes
3 answers
Destroying Prefabs Object After Spawn Using collision
I currently have some objects spawning from a prefab and am attempting to destroy only one of the spawned items of that prefab. I was searching online and I found tons of different examples but I have been unable to get any of them to work. I tried…
user10355389
3
votes
3 answers
python: will an class with many methods take longer to initialize?
I have a program that must continuously create thousands of objects off of a class that has about 12–14 methods. Will the fact that they are of a complex class cause a performance hit over creating a simpler object like a list or dictionary, or even…

kelvinsong
- 218
- 1
- 7
3
votes
1 answer
Difference between Map and Map<>?
What is he difference between two approaches of instantiating a map:
Map map = new TreeMap();
and
Map map = new TreeMap<>();
and which one is better?

Dhanesh Khurana
- 159
- 1
- 13
3
votes
6 answers
Object initialized in other class's method isn't referenced by calling method in C#
I have a class where I declare an object, but don't initialize the object. Then I pass the object to a method in another class for initialization. What I expect to happen is that the object in the calling class will now have a reference to the…
user2211907
2
votes
1 answer
Creating new object with dynamic variables in PHP
I want to create a new object using this
$procedure = new ${$s.'\\'.$p};
It doesn't work. Why isn't this possible?

x74x61
- 423
- 6
- 18
2
votes
5 answers
Hide cached objects in jQuery
I'm not sure if "cached" is a correct term for this one. Maybe I should use "instantiated" instead. However, say I want to "cache" several objects, to save some resources:
var $foo = $("#foo"),
$bar = $("#bar");
Now, if I want to hide them, can I…

aL3xa
- 35,415
- 18
- 79
- 112
2
votes
3 answers
Local variable in recursion retaining values?
Currently working on recursion practice/implementation and noticed something that goes against everything I know to be true in programming.
Recursive method
protected int getArea() {
if(width <= 0)
return 0;
else if(width == 1)
…

Matthew
- 817
- 1
- 13
- 39
2
votes
1 answer
Single line class declaration and instantiation
I've stumbled upon code using the following syntax.
int main(){
class foo{
public:
int x;
foo(int y){x=y;}
}
* bar = new foo(1);
}
Is there any purpose/consequence of using it compared to the more common
int main(){ …

xvan
- 4,554
- 1
- 22
- 37
2
votes
1 answer
Dynamically instantiating objects
I'm attempting to instantiate an object from a string. Specifically, I'm trying to change this:
from node.mapper import Mapper
mapper = Mapper(file)
mapper.map(src, dst)
into something like this:
with open('C:.../node/mapper.py', 'r') as f:
…

Gadzooks34
- 1,718
- 2
- 20
- 29
2
votes
1 answer
Jython: Instantiating java class in script as Java object, not as Python object
I have a problem when using Jython, but I can't seem to find a solution in the documentation.
Basically what I have is an object that has been instantiated in Java, and I want to instantiate another Java object (in the python script) and have the…

Aidos
- 2,753
- 3
- 27
- 31
1
vote
1 answer
How to instantiate a tile on the end of another moving tile?
I'm trying to create an "Endless runner" game, where the player remains stationary on the origin of the axes while the tiles scroll with a fixed speed on the Z-Axis as they are instantiated.
The script attached spawns 5 tiles at the start while…

Luckydraw
- 13
- 3
1
vote
2 answers
Unity: Get the position of the last cloned instantiated object
I'm trying to create an infinite ground for Android using Unity. Trying to use object pooling to achieve the ground repeating but is proving a bit tricky.
I can get my ground to Instantiate and create the clones along x axis.
What I am trying to…

Oran C
- 109
- 11
1
vote
1 answer
Confusion - Member Availability in Java
This is a Java question:
When instantiating an Object that has a Reference type that is different from the Object type, what are the scenarios that determine member availability?
For example:
Shape shp = new Square(2, 4); //Where Square extends…

Splink01
- 11
- 3
1
vote
4 answers
Is it possible to extend the functionality of an object or to Import methods into an object in PHP?
I am facing a serious design problem that is driving me crazy. I think it can only be solved with multiple inheritance or something. So here is what I want to do:
Say I have a basic user class called OrdinaryUser defined in this way:
class…

fabio
- 2,269
- 5
- 22
- 34