Hello,
In JavaScript, it seems you can do either write:
new Date().getTime();
...or:
(new Date).getTime();
The first one is logical, but the second one seems a little unusual to me... Is there any difference between these two ways of creating a Date object, and what is the purpose of the second?
Thanks,
Steve
...
I've created a class with properties that have default values. At some point in the object's lifetime, I'd like to "reset" the object's properties back to what they were when the object was instantiated. For example, let's say this was the class:
public class Truck {
public string Name = "Super Truck";
public int Tires = 4;
pu...
I definitely remember seeing somewhere an example of doing so using reflection or something. It was something that had to do with SqlParameterCollection which is not creatable by a user (if I'm not mistaken). Unfortunately cannot find it any longer.
Can anyone please share this trick here? Not that I consider it a valid approach in deve...
My java skills are limiting me from doing what I want to do.
I am trying to use the Interactive Brokers Java API to see if I can do some algorithmic trading (on paper initially). I want to call a method called ReqMktDepth() which is in a class called EClientSocket.
The EClientSocket constructor requires an object of type AnyWrapper to ...
Is it possible to declare a variable in c++ without instantiating it? I want to do something like this:
Animal a;
if( happyDay() )
a( "puppies" ); //constructor call
else
a( "toads" );
Basially, I just want to declare a outside of the conditional so it gets the right scope.
Is there any way to do this without using pointers ...
Why does the following:
class A(object):
def __init__(self, var=[]):
self._var = var
print 'var = %s %s' % (var, id(var))
a1 = A()
a1._var.append('one')
a2 = A()
result in:
var = [] 182897439952
var = ['one'] 182897439952
I don't understand why it is not using a new instance of a list when using optional keyword arg...
This post goes to a gap in my understanding of C# classes and why they are preferable to static functions.
I am trying to get a List of objects. Each object in the list represents a record in a table. This would be easy to do in a static function.
Using a class, I've been able to do it as follows:
Calling routine:
ListOfBusinesse...
I have a simple web service that uses an oracle database. When I test the service internally it works fine, however, calling the web service through my client (on the same machine but in a different WAR) throws an invocationtargetexception. I've finally discovered it's an issue with instantiating the OracleDriver. It doesn't throw any...
Is it ok to instantiate an object in a View before passing it to a partial?
<%= render :partial => "trade_new", :locals => {:trade=>Trade.new("e", "b") } %>
Or is better to instantiate any objects in the Controller as instance variables:
@trade = Trade.new("e", "b")
and then pass the instance variable to a partial in the view like ...
I have this App that uses the Webbrowser control to do automated browsing. I need to come up with a way to automatically close the browser (dispose), then create another instance that actually works.
Here's some of the code that I have so far.
this.webBrowser2 = new System.Windows.Forms.WebBrowser();
this.webBrowser2.Dock = System.Win...
The code below consists of two classes:
SmartForm (simple model class)
SmartForms (plural class that contains a collection of SmartForm objects)
I want to be able to instantiate both singular and plural classes like this (i.e. I don't want a factory method GetSmartForm()):
SmartForms smartForms = new SmartForms("all");
SmartForm sm...
I want to be able to instantiate any object in my application with this kind of code:
SmartForm smartForm = SmartForm.Create("id = 23");
Customer customer = Customer.Create("id = 222");
I'm now debating what Create() should return if that object does not exist.
if Create() returns an empty object, then this is kind of a "null patter...
In abstract factory you declare a type which is responsible for creating objects.
This would prevent requiring switch's like this:
if( type == ONE ) {
doOne();
} else if( type == TWO ) {
doTwo();
} etc.
Or the same:
switch( type ) {
case ONE: doOne(); break;
case TWO: doTwo(); break;
etc....
}
In...
Let's say I have a Type called type.
I want to determine if I can do this with my type (without actually doing this to each type):
If type is System.Windows.Point then I could do this:
Point point1 = new Point();
However if type is System.Environment then this will not fly:
Environment environment1 = new Environment(); //wrong
So...
Suppose that I have class C.
I can write o = C() to create an instance of C and assign it to o.
However, what if I want to assign the class itself into a variable and then instantiate it?
For example, suppose that I have two classes, such as C1 and C2, and I want to do something like:
if (something):
classToUse = C1
else:
class...
In F# I can do this:
type coord = float * float //Type for a 2D-float-tupple
let myDepthCurve1 = { coords = [(1., 2.); (3., 4.)]; depth = 9.4 }
but I can't do this:
type coord = { longitude : float; latitude : float } //Type for a 2D-float-record
let myDepthCurve1 = { coords = [(longitude = 1., latitude = 2.); (longitude = 3., latit...
Could someone expand and clarify the different logical instantiations of objects in actionscript? So far it seems there are 3 layers of instantiations, for lack of a better term.
The first one is declaring a variable/type.
Next is instantiating that variable with something solid in the code, like a method or function? Is this jus...
Hi, I've got a problem with VB6. I have a form with several ComboBox objects on it. I wish to populate the ComboBoxes via a function that takes a SQL query as a parameter. So the code looks like this
Private Function FillComboBoxFromMDB(ByVal sDBName As String, _
ByVal sSQL As String) As ComboBox
...
I'm just starting iPhone development (coming fron a .Net world) and have been going through many "Hello World" applications to get the hang of this new development platform. One area I have been confused with is the instantiation of a view controller. On an Apple "Hello World" tutorial, they start by creating a Window Based App, which by...
I'm writing a game in Python with the Pygame2 multimedia library, but I'm more accustomed to developing games with ActionScript 3. In AS3, I don't think it was possible to store an object in a static variable, because static variables were initialized before objects could be instantiated.
However, in Python, I'm not sure if this holds ...