|
I would like to know whats faster. Help me out.
I have a variable declared in a Method like so:
public static Regex FindNumber() { return new Regex(@"\d+", RegexOptions.IgnoreCase | RegexOptions.Compiled); }
As you can see it returns a Regular Expression...
Started by Scott on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
To you is why are you using a function call to return the same string over and over? Why don't you just declare a real variable?
Like,
private static Regex _findNumber = new Regex(@"\d.
|
|
Hello,
my Python class has some variables that require work to calculate the first time they are called. Subsequent calls should just return the precomputed value.
I don't want to waste time doing this work unless they are actually needed by the user....
Started by Richard on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Every time after, age exists so __getattr__ doesn't get called
Yes you can use.
To access age.
|
|
I'm confused about these two keywords and the way to use them in PHP5. I think that "this" is used for instanced objects (not static) while "self" is referring to the object itself, not an instance of it and thus used within static objects. Right?
Now...
Started by Tom on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
YourClass::staticFunction is being called through an instantiated....
This when not in object context
This results in a fatal error because foo() was called statically and could be called without an instance of the object being created.
|
Ask your Facebook Friends
|
I need to make a grand total of the items I'm counting in a subReport. To do that, I think I need to add the value of that variable to another variable for each iteration, or "increment" it by that value. The subReport gets called for each group, and ...
Started by sventech on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
In the variable expression, you will need something like $V{grandCount} = $V{grandCount} + $V{itemCount}
NOTE: JasperReports render....
Variable, with class type "Integer", and calculation type "System" The calculation type is important here.
|
|
I want to tell my function which variable to call based on the day of the week. The day of the week is stored in $s_day, and the variables I want to call changes based on which day it is.
e.g.
I've stored a string 'Welcome to the week' in $d_monday_text...
Started by jkramp on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
They suit this problem much, much.
Variable variables aren't a good idea - You should rather use arrays.
|
|
Let's say I have the following class:
class SQLMapper{ static find_user_by_id($id){ //sql logic here, using the $_DATABASE global to make a connection } }
I could simply call:
global $_DATABASE;
at the top of my function, but I don't want to do that for...
Started by Mike Trpcic on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
For example:
query of that variable:
class SQLMapper { static function getDatabase() { global $_DATABASE; return.
Can use the super-global array $_GLOBALS to access your $_DATABASE variable.
|
|
I am reviewing some ClearCase triggers written in Perl. I have noticed that in some regular expressions, variables are passed either straighforwardly or with their names in curly brackets.
For example, I have the following line of code in a trigger:
if...
Started by Thomas Corriol on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If you pass the variable as ${name}, this explicitly delimits where the end of the variable name:
if ($baseline !~ /^$component_(|.*_)$phase\.\d+(|[a-z]|-\d+|${automateddigit})$/ &&
Note that the variable of the trailing underscore....
|
|
Ok, this is veeery weird... I think. What I mean with the title is:
inside the act() function from an actionHandler object I have:
state->getHumanPieces();
Which gives me an address violation of some sort, apparently 'this' does not have a 'state' ...
Started by Zepee on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
For instance, take an object nor the state variable from within....
Something like this is happening static methods are not called from a particular instance of an object.
Your this pointer is null.
Is getting called on a null pointer.
|
|
Hi,
In PHP, say that you have some code like this:
$infrastructure = mt_rand(0,100); if ($infrastructure < $min_infrastructure) $infrastructure = $min_infrastructure; //do some other stuff with $infrastructure $country->set_infrastructure($infrastructure...
Started by Philip Morton on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Hope this....
You could simply call $the_fish->getName(); where you'd use $the_fish.
To answer your question: Yes, you can use variables as variable names, using the ${$varname} syntax that information is now stored in the object...
|
|
Hi folks, I'm doing these free online Stanford classes and learning Java. I'm stuck on something and haven't been able to figure it out. I think there must be something wrong with my logic. Please check out the code below. I commented it, so hopefully...
Started by Joel on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
So you can not call on them in your object initialization block (in your of the pyramid are set during the constructor so getWidth and getHeight default to 0.0 when called, you have to call the function....
Methods, not static methods.
|