Questions tagged [method-call]
386 questions
9
votes
5 answers
'@' symbol prefix on c# method call?
Possible Duplicate:
What's the use/meaning of the @ character in variable names in C#?
I was doing some .net development and I noticed I could add an @ symbol before any method call, i.e.:
var message = dog.@SayHello();
Just wondering, why is…

Jose R. Cruz
- 909
- 2
- 9
- 15
9
votes
4 answers
What is the best way to call a method right AFTER a form loads?
I have a C# windows forms application. The way I currently have it set up, when Form1_Load() runs it checks for recovered unsaved data and if it finds some it prompts the user if they want to open that data. When the program runs it works alright…

PICyourBrain
- 9,976
- 26
- 91
- 136
9
votes
4 answers
C# & generics - why is method in base class called instead of new method in derived class?
If the generic type argument (of either a calling class or calling method) is constrained with where T : Base the new method in T == Derived is not called, instead the method in Base is called.
Why is the type T ignored for method call even though…

Roland Pihlakas
- 4,246
- 2
- 43
- 64
8
votes
2 answers
How to call method inside the same class in ReactJS?
I want to call the method inside the same class. For example, when I click a button, it will trigger the method handleLoginBtnClicked(). I expect it will call the method checkInputValidation() in the same class. What is the proper way to do…

Casper
- 4,435
- 10
- 41
- 72
7
votes
1 answer
How to pass objects to keywords in robot framework?
I have a python class MyClass written in file MyClass.py:
class MyClass(object):
def __init__(self):
self.myvar = list()
def setvar(self, val):
self.myvar = val
def mymethod(self):
return self.myvar
I have…

Sara Sarvi
- 71
- 1
- 4
7
votes
4 answers
Java compiler optimization for repeated method calls?
Does the java compiler (the default javac that comes in JDK1.6.0_21) optimize code to prevent the same method from being called with the same arguments over and over? If I wrote this code:
public class FooBar {
public static void main(String[]…

Rafe Kettler
- 75,757
- 21
- 156
- 151
7
votes
7 answers
How to call the method in thread with arguments and return some value
I like to call the method in thread with arguments and return some value here example
class Program
{
static void Main()
{
Thread FirstThread = new Thread(new ThreadStart(Fun1));
Thread SecondThread = new Thread(new…

ratty
- 13,216
- 29
- 75
- 108
7
votes
4 answers
How to enforce a method call (in the base class) when overriding method is invoked?
I have this situation that when AbstractMethod method is invoked from ImplementClass I want to enforce that MustBeCalled method in the AbstractClass is invoked. I’ve never come across this situation before. Thank you!
public abstract class…

Jeff
- 13,079
- 23
- 71
- 102
6
votes
2 answers
JavaScript - Attach context to async function call?
Synchronous function call context
In JavaScript, it's easy to associate some context with a synchronous function call by using a stack in a global scope.
// Context management
let contextStack = [];
let context;
const withContext = (ctx, func)…

David Callanan
- 5,601
- 7
- 63
- 105
5
votes
2 answers
Rails I18n: shorten the translate calls (at least in the views)
What is the DRY way to translate certain fields?
In my RESTful views, I have some repeating snippets, like this in a show-view:
...
<%= t("activerecord.attributes.user.firstname") %>
<%= @user.firstname %>
...
Now, instead of…

DMKE
- 4,553
- 1
- 31
- 50
5
votes
10 answers
can we call any method on null object?
is it possible?
Object obj=null;
obj.someMethod();
someMethod{/*some code here*/}

Anand
- 51
- 1
- 1
- 2
5
votes
1 answer
How to verify a non-mocked method was called?
I want to test that my method calls another method in the same class that I cannot mock.
Example:
public void methodToTest(){
//other stuff to test that can be mocked
someClassICanMock.doSomething();
//method within same class that cannot be…

java123999
- 6,974
- 36
- 77
- 121
5
votes
3 answers
Why do we bypass instance attributes during implicit lookup of special methods?
From the ‘Special method lookup for new-style classes’ section of the ‘Data model’ chapter in the Python documentation (bold emphasis mine):
For new-style classes, implicit invocations of special methods are only guaranteed to work correctly if…

Determinant
- 3,886
- 7
- 31
- 47
4
votes
6 answers
Java calling method and using ternary operator and assign in the parameters?
I was reviewing some code and I came across this:
public static doSomething(String myString, String myString2) {
//Stuff
}
public static doAnotherThing(String myString) {
return doSomething(myString = myString != null ?…

Oscar Gomez
- 18,436
- 13
- 85
- 118
4
votes
1 answer
Why can't we use a CALL :label command in the FORFILES script?
This snippet of code
forfiles /P %pathname% /M *.log /c "cmd /c echo @file"
will happily list out a bunch of files.
We could replace the ECHO with RENAME or MOVE or many other combinations of internal commands: the exception being a CALL to a label…

ilinkcs
- 142
- 8