I have a function that accepts n
number of parameters (it's the devinus/sh function) where you can execute a command line program and obtain the results:
Example: Sh.file "-b", "--mime-type", path_to_file
But I want to have the parameters in an array so they can be varying depending on how the function is called.
Example of what I want:
data = ["-b", "--mime-type", path_to_file]
# a way of going through the array and turning it into the parameters for the Sh function
Sh.file <loop array params here>
Sh doesn't take an array for a parameter.
Any ideas?
Passing Arrays as Function Arguments in C. If you want to pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in one of following three ways and all three declaration methods produce similar results because each tells the compiler that an integer pointer is going to be received.
Arrays in query params. The same way there is no concensus over… | by Jonathan Stoikovitch | RAML by Example | Medium The same way there is no concensus over how objects should be represented in query parameters, there is no standardized way to format arrays of values in query parameters.
Below are methods to convert Array to List in Java: Brute Force or Naive Method: In this method, an empty List is created and all elements present of the Array are added to it one by one. Using Arrays.asList() method: In this method, the Array is passed as the parameter into the List constructor with the help of Arrays.asList() method.
var args = ; function call_me (param0, param1, param2) { // ... } // Calling the function using the array with apply () call_me.apply (this, args);
You can use apply(Sh, :file, args)
, where args
is an array of arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With