I have a function 'foo' and a variable '$foo' referencing it.
function foo
{
param($value)
$value + 5
}
$foo = foo
$foo
I can call $foo without args, but how can I pass parameters? This does not work:
$foo 5
$foo(5)
Actually the goal is to write such code:
function bar {
param($callback)
$callback 5
}
bar(foo)
...
Consider the case of a templated function with variadic template arguments:
template<typename Tret, typename... T> Tret func(const T&... t);
Now, I have a tuple t of values. How do I call func() using the tuple values as arguments?
I've read about the bind() function object, with call() function, and also the apply() function in diffe...
I have a friendly argument going on with a co-worker about this, and my personal opinion is that a ASP.NET-MVC compiled web application would run more efficiently/faster than the same project that would be written in PHP. My friend disagrees.
Unfortunately I do not have any solid data that I can use to back up my argument. (neither doe...
The program is supposed to calculate the number of arguments, iterate over the list of arguments, for each argument convert the argument to an integer and copy it to an array, iterate over the elements of the array, adding the value of each one to a variable (this computes the sum of elements), and print the sum. There will not be more t...
Using VB.NET, is there a way to pass a reference argument when invoking a function in a dll.
Suppose I want to pass arg2 as a reference argument, how would I do that?
method.Invoke(obj, New [Object]() {arg1, arg2, arg3})
In other words I want to point arg2 to something else within the invoked function.
...
It's somewhat common knowledge that Python functions can have a maximum of 256 arguments. What I'm curious to know is if this limit applies to *args and **kwargs when they're unrolled in the following manner:
items = [1,2,3,4,5,6]
def do_something(*items):
pass
I ask because, hypothetically, there might be cases where a list lar...
I am working on some simple object-oriented code in MATLAB. I am trying to call one of my class methods with no input or output arguments in its definition.
Function definition:
function roll_dice
Function call:
obj.roll_dice;
When this is executed, MATLAB says:
??? Error using ==> roll_dice
Too many input arguments.
Error in ==> ...
I am trying to detect whether the 'a' was entered as the first string argument.
...
Since arguments sent to a method in Java point to the original data structures in the caller method, did its designers intend for them to used for returning multiple values, as is the norm in other languages like C ?
Or is this a hazardous misuse of Java's general property that variables are pointers ?
...
Consider such function:
function Test($foo, $bar)
{
...
}
We can call it:
Test -foo $null
Test
How can I know when the -foo was omitted, and when it was $null?
...
Consider such function:
$missed = "{716C1AD7-0DA6-45e6-854E-4B466508EB96}"
function Test($foo = $missed, $bar = $missed)
{
if(!$foo)
{
throw "error"
}
if(!$bar)
{
throw "error"
}
}
I whould like to call this function this way
Test -foo $foo -bar $bar
But if $foo or $bar is $null, exception will be thrown. The ...
Is there a way to use each of the arguments in this function in sequence without duplicating code? For example, the first time through the loop I'd like to use R, the next time I'd like to use L, etc. valuestruct is set up in the same order as the arguments, so the button method will return the equivalent bool I need for currentbutton ...
I have a system which I've been wrestling with for a while. Essentially, it uses a lot of abstraction to deal with the fact that later extension is not just expected, but necessary. One place this is required is data access. The system generally deals with managing objects encapsulating some observation (in the sense of an observed value...
Okay I have to write a program that accepts 2 or more arguments and searches the second and remaining arguments for a matching argument.
for example the output would be:
./a 3 h 4 9 3
3 found
or
./a hsi and iash me 34 hsi
hsi found
So far I have this, and I'm pretty sure I've got a lot of junk in here that is useless in the...
I keep getting told that in this line of code passing argument from incompatible pointer type.
Here's the line of code:
if (linear_search (size_of_A, argv[i]))
What does this mean and how do I fix it? Here is the whole program:
int linear_search ( int size_of_A, char*argv[]){
int i;
i = 2;
while (i <= size_of_A - 1...
Is there a better way to require that an argument is not null in a method? I keep checking if any of the arguments that my method requires are null, as show below. But I'm wondering if there is a better way.
public void MyMethod(string a, int b)
{
if(a==null){throw new ArgumentNullException("a");}
if(b==null){throw new ArgumentNul...
I'm writing a merge sort function, and right now I am just using a test case array (there is no input - this is static, for now). I don't know how to pass an array as an argument. Here is my code right now:
//merge sort first attempt
#include <iostream>
#include <algorithm>
#include <vector>
int mergeSort(int[]);
int main()
{
int orig...
Using Visual Studio / C#, I've been debugging some nunit tests recently, and am now trying to make sure that if we branch the code that the unit tests don't stop working in debug mode.
I have this working by changing project properties to launch NUnit as an external program:
C:\Program Files\NUnit 2.4.8\bin\nunit-console.exe
..and th...
Hi Perl followers.
I am having trouble getting Params::Validate to work how I want it to.
#!/usr/local/bin/perl -w
use strict;
use Params::Validate qw/:all/;
use Data::Dumper;
sub foo {
my %args = validate(@_, {
bar => {
default => 99,
# TODO - Somehow use a callback to return a default if undefine...
Is there a way in C++ where an objects has argument added upon it, with an array such as:
int x = 1;
int y = 2;
Object myObject( x, y )[5]; // does not work
I was hoping that I could put arguments into the object, while creating an array of 5 of these objects, does anyone know how? and is there a bteter way?
...