Questions tagged [method-parameters]
65 questions
                    
                    42
                    
            votes
                
                4 answers
            
        How to get Method Parameter names in Java 8 using reflection?
Java 8 has the ability to acquire method parameter names using Reflection API.
How can I get these method parameter names?
As per my knowledge, class files do not store formal parameter names. How can I get these using reflection?
         
    
    
        Prateek
        
- 12,014
- 12
- 60
- 81
                    15
                    
            votes
                
                6 answers
            
        Are method parameters thread safe in Java?
Class Shared{    
     public void sharedMethod(Object o){
          //does something to Object
     }     
}
//this is how threads call the shared method
run(){
     sharedInstance.sharedMethod(someObject);
}
Now the o is being passed as the…
         
    
    
        Narendra Pathai
        
- 41,187
- 18
- 82
- 120
                    12
                    
            votes
                
                2 answers
            
        Ehcache automatic key generation and @Cacheable spring annotation
Does anybody know how the default key generation for Ehcache works? If I have the following method:
@Cacheable(cacheName = CACHE_KEY) // CACHE_KEY is static final field.
public List list(
    int firstRecord, int maxRecords, int… 
         
    
    
        Ivaylo Slavov
        
- 8,839
- 12
- 65
- 108
                    9
                    
            votes
                
                3 answers
            
        Is there a way to let arguments be var instead of val?
When debugging command line argument handling in Java I'm used to doing
args = new String[] { "some", "new", "arguments" };
(especially useful if have a filename as argument which you frequently change, but don't want to go through some dialog…
         
    
    
        aioobe
        
- 413,195
- 112
- 811
- 826
                    8
                    
            votes
                
                2 answers
            
        Is mutating object-parameters in a method(in Java) a bad practice?
I have a question about mutating method-paramaters(which are objects) in a method. 
I read and heard multiple times that it is a bad practice to mutate a object in a method which was passed in as a paramater. As example:
public void…
         
    
    
        MaverinCode
        
- 469
- 1
- 4
- 15
                    6
                    
            votes
                
                5 answers
            
        How to use PHP function or method arguments in any order?
Lets say I define class with method like this:
class Test {
    public function doStuff($a, $b, $c) {
    // -- Do stuff --
    }
}
Is it possible to use this method but with arguments in different order, like this:
$test = new…
         
    
    
        otporan
        
- 1,345
- 2
- 12
- 29
                    5
                    
            votes
                
                0 answers
            
        How should one handle iOS version-specific UIApplicationDelegate protocol method parameter types?
In iOS 12, the UIApplicationDelegate protocol defines:
- (BOOL) application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> *… 
         
    
    
        Alexander Gingell
        
- 332
- 2
- 17
                    4
                    
            votes
                
                1 answer
            
        Resharper and live templates. Get the list of parameters in a method
I want to create a live template with resharper that allows me to write logging information inserting method name and method parameters, something like this:
I have in my code, a method like this:
public void searchByParams(String param1, String…
         
    
    
        Fernando Moyano
        
- 1,097
- 4
- 15
- 29
                    3
                    
            votes
                
                3 answers
            
        How to Convert Array to Params of Method?
I need to pass params (like: 'param1', 'param2', 'param3') to the method... but I have array of params (like: array('param1', 'param2', 'param3')). How to convert array to params?
function foo(array $params) {
    bar(
        // Here should be…
         
    
    
        daGrevis
        
- 21,014
- 37
- 100
- 139
                    3
                    
            votes
                
                1 answer
            
        How to pass a reference to a STATIC method as a function parameter in C#?
I need to use a Swallow(Func) method from NLog library. 
Important note: I call Swallow from a static method and want to pass a static method.
Its documentation is…
         
    
    
        Sold Out
        
- 1,321
- 14
- 34
                    3
                    
            votes
                
                2 answers
            
        Java: get all method parameters as Object array
Is it possible to do this:
void foo(Bar b, FooBar fb){
    Object[] args=getArgs() //Contains the parameters b & fb
}
And if yes, how?
(I dont know the name and the number of parameters)
         
    
    
        flimmerkiste
        
- 261
- 1
- 4
- 7
                    3
                    
            votes
                
                2 answers
            
        How to conditionally pass parameters into a func array
I have method that expects the following parameters:
public IQueryable GetAllIncluding(params Expression>[] includeProperties)
{
    foreach (var includeProperty in includeProperties)
    {
       …  
         
    
    
        RichC
        
- 7,829
- 21
- 85
- 149
                    3
                    
            votes
                
                1 answer
            
        python - create a dynamic list of parameter for a method
I want to create a XLSX file in python. For this, I use xlsxwriter.
In my XLSX I want to highlight some part of text with the write_rich_string method.
But, my string is not a fixed value. The part I want to highlight can be randomly placed into it.…
         
    
    
        gatchan
        
- 75
- 2
- 7
                    3
                    
            votes
                
                1 answer
            
        Should I validate method parameters in Ruby?
I have Java background and in Java when programmer call method with wrong parameters, exception will be thrown. How Ruby programmers treat wrong method arguments?
Two opposite examples from core classes:
irb(main):009:0> "" * (-2)
ArgumentError:…
         
    
    
        guest
        
- 1,696
- 4
- 20
- 31
                    2
                    
            votes
                
                1 answer
            
        How to get from a Method to the Annotations of its Parameters during Annotation-processing?
During annotation processing I am currently processing the annotation of a method:
@Override
public boolean process(Set extends TypeElement> elements, RoundEnvironment env) {
  Messager msg = processingEnv.getMessager();
  for (TypeElement te :…
         
    
    
        towi
        
- 21,587
- 28
- 106
- 187