Questions tagged [method-signature]

In computer programming, especially object-oriented programming, a method is commonly identified by its unique method signature, which usually includes the method name, and the number, types and order of its parameters. A method signature is the smallest type of a method.

method-signature
Filter by
Sorted by
Tagged with
169 votes
1 answer
92k views

Static member functions error; How to properly write the signature?

I am getting an error when trying to compile my code in g++ using the current signature: cannot declare member function static void Foo::Bar(std::ostream&, const Foo::Node*) to have static ...
Joshua's user avatar
  • 4,300
107 votes
14 answers
85k views

Does a method's signature in Java include its return type?

Does the method signature in a Java class/interface include its return type? Example: Does Java know the difference between those two methods: public class Foo { public int myMethod(int param) ...
faressoft's user avatar
  • 19.4k
82 votes
3 answers
10k views

What is double exclamation mark in C#?

From https://source.dot.net/#System.Private.CoreLib/Hashtable.cs,475: public virtual bool ContainsKey(object key!!) It looks like two null-forgiving operators. Is there a document about it?
shingo's user avatar
  • 22.3k
73 votes
6 answers
44k views

Inheritance best practice : *args, **kwargs or explicitly specifying parameters [closed]

I often find myself overwriting methods of a parent class, and can never decide if I should explicitly list given parameters or just use a blanket *args, **kwargs construct. Is one version better than ...
Maik Hoepfel's user avatar
  • 1,777
50 votes
5 answers
186k views

How to return an array from a function?

How can I return an array from a method, and how must I declare it? int[] test(void); // ??
ewggwegw's user avatar
  • 4,342
49 votes
7 answers
42k views

How to get method signatures from a jar file?

I have a third-party jar file that comes with the javadocs for only part of the API. Is there a way to reverse engineer the jar file to obtain a complete listing of classes and methods?
MCS's user avatar
  • 22.3k
38 votes
5 answers
38k views

C++ typedef member function signature syntax

I want to declare type definition for a member function signature. Global function typedefs look like this: typedef int (function_signature)(int, int); typedef int (*function_pointer) (int, int); But ...
0xbadf00d's user avatar
  • 17.8k
32 votes
7 answers
22k views

Compute a Java function's signature

Is there a way to compute a Java class's method's signature? A signature like ([Ljava/lang/String;)V represents a function that takes a String[] as argument and returns void. What's the rule to ...
Niklas R's user avatar
  • 16.6k
29 votes
3 answers
72k views

How do you resolve a "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues" error

I am getting this error: "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues." in my Google Apps Script when I try to write an array of values to a ...
Nico's user avatar
  • 295
25 votes
7 answers
36k views

Definition of a method signature?

What is the correct definition of a method signature (or a signature of a method)? On google, I find various definitions: It is the combination of the method name and the parameter list Does that ...
KMC's user avatar
  • 19.9k
25 votes
4 answers
2k views

Why are jQuery's callback arguments inconsistent?

A common pattern within jQuery is a method that takes a callback which is passed an element of an array and its index within that array. However, it seems completely random which argument comes first....
brad's user avatar
  • 74.8k
24 votes
5 answers
10k views

Why varargs should be the last in a method signature?

If I try to write a method like below public void someStuff(Object ... args, String a ) I get this error The variable argument type Object of the method someStuff must be the last parameter. I ...
Ravi Gupta's user avatar
  • 4,538
23 votes
3 answers
15k views

Is it possible to pass a method as an argument in Objective-C?

I have a method that varies by a single method call inside, and I'd like to pass the method/signature of the method that it varies by as an argument... is this possible in Objective C or is that too ...
eriaac's user avatar
  • 963
20 votes
2 answers
3k views

What is "override-equivalence" and how is it related to @Override?

Reading the Javadoc for the @Override annotation, I came across the following rule: If a method is annotated with this annotation type compilers are required to generate an error message unless at ...
Octahedron's user avatar
19 votes
1 answer
38k views

Sheet.getRange throwing signature mismatch exception when not using A1 notation

I'm writing a script on a Google Sheet that will be interacting with Google Map's Geocoding service. The following code works correctly. var ss = SpreadsheetApp.getActiveSpreadsheet(); var header_v = ...
Benjamin Didur's user avatar
19 votes
4 answers
5k views

Delegate for any method type - C#

I want to have a class that will execute any external method, like this: class CrazyClass { //other stuff public AnyReturnType Execute(AnyKindOfMethod Method, object[] ParametersForMethod) { ...
Daniel Möller's user avatar
17 votes
6 answers
28k views

Call function in c++ dll without header

I would like to call a method from an dll, but i don't have the source neither the header file. I tried to use the dumpbin /exports to see the name of the method, but i can found the methods signature?...
mileschet's user avatar
  • 371
17 votes
1 answer
3k views

What are the digits in an ObjC method type encoding string?

I'm reading Apple's article about Objective-C runtime type encoding strings and some methods have numbers in their type strings. What do the numbers in v12@0:4@8 mean?
Ecir Hana's user avatar
  • 11.1k
17 votes
5 answers
54k views

How do you fix the following error : A problem occurred evaluating project ':app'. > No signature of method:

I am getting the following error when trying to run my react-native app with android and I am unsure why, any ideas? *Where: Build file '/Users/ahmeeyagoldman/Documents/TikTok/android/app/build.gradle'...
Ahmeeya Goldman's user avatar
15 votes
1 answer
9k views

Is it possible to write a Rust macro that will expand into a function/method signature?

I would love to be able to something like the following: macro_rules! impl_a_method( ($obj:ident, $body:block) => ( fn a_method(foo: Foo, bar: Bar, baz: Baz) -> $obj $body ) ) /...
mindTree's user avatar
  • 936
14 votes
5 answers
4k views

How can an interface include a method that references the concrete implementation type of the interface in its signature or return type?

Suppose I am designing something like the following interface: public interface MyInterface{ public MyInterface method1(); public void method2(MyInterface mi); } However, there is the caveat ...
Michael McGowan's user avatar
12 votes
3 answers
729 views

Why does Stream.Write not take a UInt?

It seems highly illogical to me that Stream.Write uses int, instead of UInt... Is there an explanation other than "legacy" code for this fact? Would any one want to write -1 bytes?!?
Leonardo's user avatar
  • 11.2k
12 votes
5 answers
5k views

Android studio breadcrumb method signature

I am looking for Breadcrumb functionality like Eclipse in Android Studio. In Eclipse Breadcrumb shows "method signature" when pointer(cursor) come inside whereas in Android Studio Breadcrumb is good ...
Amit Yadav's user avatar
  • 33.6k
12 votes
12 answers
473 views

Design question: pass the fields you use or pass the object?

I often see two conflicting strategies for method interfaces, loosely summarized as follows: // Form 1: Pass in an object. double calculateTaxesOwed(TaxForm f) { ... } // Form 2: Pass in the fields ...
Kyle Kaitan's user avatar
  • 1,771
12 votes
4 answers
904 views

How can I make perltidy work with Method::Signatures?

I'm using Eclipse combined with EPIC to write my Perl code. I configured EPIC to use Perltidy with "-pbp" (perl best practices style) to format my code. This doesn't work well when using Method::...
David B's user avatar
  • 29.6k
12 votes
5 answers
10k views

How to generate method signature?

Desired output examples: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node; (Ljava/lang/String;)Lorg/w3c/dom/Attr; Such signatures can be generated using javap utility: javap -s -p org.w3c.dom.Node But is ...
alex2k8's user avatar
  • 42.9k
11 votes
6 answers
562 views

How should be my Service method signature?

I'm using a Service Layer, and until now I used a ServiceObject (which implements ArrayAccess, Iterator, Countable) but I'm wondering if it's a good ideas. Would you do: ArticleService::...
JohnT's user avatar
  • 967
10 votes
3 answers
2k views

What does this signature mean (&) in PHP?

Consider: public function & get($name, $default = null) Why &?
user198729's user avatar
  • 62.8k
10 votes
2 answers
183 views

Perl 6 multi methods never match expected signature

I have a class with two multi methods (multi submit). I call my multi like this: $perspective.submit(:message($message.content)); Which gets shipped off to my class: my $perspective-api = API::...
kawaii's user avatar
  • 301
10 votes
1 answer
282 views

Can I name a function signature?

I'm passing around a partially applied function. The full signature is: import Data.Map as Map -- Update the correct bin of the histogram based on the min value, bin width, -- the histogram stored ...
Tim Perry's user avatar
  • 3,086
10 votes
3 answers
10k views

Why is throws part of the method signature

Why throws, on a method, is part of its signature? It seems strange to include it. Here is an example where it is in the way: @Overide public void foo() { throw new UnsupportedOperationException();...
Dragon Creature's user avatar
9 votes
7 answers
13k views

Final keyword in method signatures [duplicate]

Possible Duplicate: Final arguments in interface methods - what’s the point? While trying to experiment a few things, I've ran into a problem that it's described in this page. interface B { ...
SHiRKiT's user avatar
  • 1,024
9 votes
3 answers
8k views

How to specify any newable type in TypeScript?

I tried with this but it doesn't work. Foo is just a test of what works. Bar is the real try, it should receive any newable type but subclasses of Object isn't valid for that purpose. class A { } ...
Áxel Costas Pena's user avatar
8 votes
2 answers
4k views

Delegates and ParamArray - Workaround Suggestions?

Some predefined methods contain a ParamArray in their signature. Delegates, however, cannot contain a ParamArray in their signature. Question: Assume you wish to create a delegation mechanism for a ...
M.A. Hanin's user avatar
  • 8,064
8 votes
7 answers
39k views

Can Java methods return type Enum?

I could be wrong but I'm guessing from Why can't enums be declared locally in a method? that, since an enum in Java cannot be declared locally, that therefore it is problematic for a method to ...
Dexygen's user avatar
8 votes
1 answer
1k views

What is difference between Generic type and Object in method declaration?

I am confused that which method Signature should I use for same purpose? Both are working fine for me. 1. public <T, J> T findUniqueByCondition(String tableName, ...
Vishal Zanzrukia's user avatar
8 votes
2 answers
4k views

C++: inheriting overloaded non-virtual method and virtual method both with the same name causes problem

I am trying to inherit two equally named methods with different parameter lists to a derived class. One of them is virtual and overridden in the derived class, the other one is non-virtual. Doing so, ...
Emme's user avatar
  • 83
8 votes
3 answers
106 views

Tool to look for incompatabilities in method signatures / fields

I would like to be able to compare two versions of a class / library to determine whether there have been any changes that might break code that calls it. For example consider some class Foo that has ...
M. Jessup's user avatar
  • 8,193
8 votes
2 answers
217 views

Overload resolution, which method is called

Lets suppose I have a ComponentBase class, who is child of ObjectContextDecorator and grandchild of ObjectContext. public class ComponentBase extends ObjectContextDecorator { } public class ...
Gabriel Robaina's user avatar
6 votes
5 answers
2k views

How to implement python method with signature like ([start ,] stop [, step]), i.e. default keyword argument on the left

Since in python 3.X the build-id range() function returns no longer a list but an iterable, some old code fails as I use range()to conveniently generate lists I need. So I try to implement my own ...
Rafael T's user avatar
  • 15.5k
6 votes
2 answers
443 views

static imports method overlap

if you have a class with a static import to java.lang.Integer and my class also has a static method parseInt(String) then which method will the call parseInt("12345") point to? Thanks in Advance!
MozenRath's user avatar
  • 9,802
6 votes
2 answers
8k views

Sublime PHP method signature and description on autocomplete

I really like sublime but I have 1 major issue stopping me from migrating from Netbeans: I need sublime autocomplete to show function description and method signature (i'm working with Yii framework ...
Danny Valariola's user avatar
6 votes
3 answers
1k views

Interface implementation with method argument superclasses

As a practical example of the general question in the subject, I'd like to implement the containsAll method in the Set interface with public boolean containsAll(Iterable<?> c) { /* ... */ } I ...
Carl's user avatar
  • 7,556
6 votes
1 answer
152 views

What's the format for `objc_method_description.types` for swift blocks?

The Objective-C method encoding produced by the Swift compiler for swift methods with blocks seems to use syntax not documented anywhere. For instance the method: func DebugLog2(message: String) async ...
Rolf Bjarne Kvinge's user avatar
6 votes
2 answers
478 views

Java - Is it possible to output the stacktrace with method signatures?

Is it possible to output the current stacktrace with method signatures? I'm trying to debug some obfuscated code that has a ton of methods with the same name that just differ in arguments and return ...
jli's user avatar
  • 6,553
5 votes
5 answers
10k views

Why can't two methods be declared with the same signature even though their return types are different? [duplicate]

Duplicate: Function overloading by return type? Maybe this is a very silly question but I don't understand why I can't declare two methods that have the same signature when they have different return ...
mezoid's user avatar
  • 28.4k
5 votes
2 answers
3k views

Why is varargs always the last parameter in a method signature?

Why does varargs have to be the last parameter in method signature? I want to know the reason.
Sam's user avatar
  • 6,830
5 votes
3 answers
16k views

How to get parameter names with Java reflection [duplicate]

How do I get method signatures with Java reflection? EDIT: I actually need the parameter NAMES not the types of a method.
javatar's user avatar
  • 4,582
5 votes
2 answers
697 views

C#: Method signatures?

Let's say I create these two methods: public void AddScriptToPage(params string[] scripts) { /*...*/ } public void AddScriptToPage(string href, string elementId) { /*...*/ } Which one of these ...
JamesBrownIsDead's user avatar
5 votes
3 answers
230 views

What is the difference between the generic signifier ' and the symbol ^ In F# method signatures

I understand the tick to signify a generic parameter, as in: Seq.append : seq<'T> -> seq<'T> -> seq<'T> but what does the caret signify, as in: Seq.average : seq<^T> -&...
Joshua Belden's user avatar

1
2 3 4 5