Questions tagged [method-call]
386 questions
394
votes
3 answers
How can I call a function within a class?
I have this code which calculates the distance between two coordinates. The two functions are both within the same class.
However, how do I call the function distToPoint in the function isNear?
class Coordinates:
def distToPoint(self, p):
…

Steven
- 4,193
- 3
- 17
- 11
293
votes
10 answers
How to get name of calling function/method in PHP?
I am aware of function debug_backtrace, but I am looking for some ready to use implementation of function like GetCallingMethodName()? It would be perfect if it gave method's class too (if it is indeed a method).

Dawid Ohia
- 16,129
- 24
- 81
- 95
107
votes
9 answers
Check if returned value is not null and if so assign it, in one line, with one method call
Java is littered with statements like:
if(cage.getChicken() != null) {
dinner = cage.getChicken();
} else {
dinner = getFreeRangeChicken();
}
Which takes two calls to getChicken() before the returned object can be assigned to dinner.
This…

Continuity8
- 2,403
- 4
- 19
- 34
52
votes
5 answers
C# method call with parameter name and colon
I've begun to notice at times when I'm making method calls in C# that the names of the parameters for the method I'm calling will show up in the intellisense list appended with a colon, and that I can then format the method call…

Zann Anderson
- 4,767
- 9
- 35
- 56
46
votes
6 answers
How to see from where a public method is called in Eclipse using Java?
I am working on a Java project in Eclipse. Sometimes when I do refactoring I would like to see from what other classes a public method is called.
There is a primitive way to do this, that I am using now. I can comment out the method and see in what…

Jonas
- 121,568
- 97
- 310
- 388
40
votes
4 answers
Passing single object vs. passing multiple parameters
Suppose I have the following
Class A {
Foo getFoo();
Bar getBar();
Baz getBaz();
}
And I need to define a function doStuff that uses Foo, Bar, Baz of one object and does some stuff
I'm struggling between which method of implementing…

Rufus
- 5,111
- 4
- 28
- 45
35
votes
3 answers
CLR implementation of virtual method calls to interface members
Out of curiosity: how does the CLR dispatch virtual method calls to interface members to the correct implementation?
I know about the VTable that the CLR maintains for each type with method slots for each method, and the fact that for each interface…

Daniel A.A. Pelsmaeker
- 47,471
- 20
- 111
- 157
26
votes
3 answers
Vue.js inheritance call parent method
Is it possible to use method overriding in Vue.js?
var SomeClassA = Vue.extend({
methods: {
someFunction: function() {
// ClassA some stuff
}
}
});
var SomeClassB = SomeClassA.extend({
methods: {
someFunction: function() {
…

MyFantasy512
- 690
- 1
- 9
- 20
24
votes
6 answers
Calling JavaScript from within CSS :hover
Is there any way that I can call a JavaScript function via css?
For example, from this :hover style:
.first-nav li a:hover,
.first-nav li.hover a {
margin:-3px 0 -1px;
height:30px;
position:relative;
…

BreakHead
- 10,480
- 36
- 112
- 165
22
votes
3 answers
"Iterating" through methods
Let's say I've got a Java object that's got among others the following methods:
public String getField1();
public String getField2();
public String getField3();
public String getField4();
public String getField5();
Is there a way to iterate through…
user321068
17
votes
2 answers
C++ method call and type scope resolution ambiguity
I hope the title actually describes what I wanted to ask...
I wrote a piece of code that compiles with gcc and works as I intended. However, it does not compile with llvm and the code executes differently when compiled with icc!
Here is an example…

Nowakus
- 571
- 4
- 7
14
votes
2 answers
Prevent strings from being interpreted as a file handle
Perl has the feature that strings named like a file handle are taken to be a filehandle:
# let this be some nice class I wrote
package Input {
sub awesome { ... }
}
So when we do Input->awesome or extra-careful: 'Input'->awesome, the method…

amon
- 57,091
- 2
- 89
- 149
10
votes
2 answers
How to add some action in constructor?
Naive question I believe, but all I find is just calling other constructors from constructors. I need to call a method. My class (beginning):
class ScopedIterator[T](val iter : Iterator[T])
{
private var had_next : Boolean;
private var value :…

greenoldman
- 16,895
- 26
- 119
- 185
10
votes
3 answers
How do I call a method of a Java instance from JavaScript?
I'm using the Mozilla Rhino JavaScript emulator. It allows me to add Java methods to a context and then call them as if they were JavaScript functions. But I can't get it to work except when I use a static method.
The problem is this part of the…

Aaron Digulla
- 321,842
- 108
- 597
- 820
10
votes
12 answers
Create a method call in .NET based on a string value
Right now, I have code that looks something like this:
Private Sub ShowReport(ByVal reportName As String)
Select Case reportName
Case "Security"
Me.ShowSecurityReport()
Case "Configuration"
…

Jim
- 11,229
- 20
- 79
- 114