Questions tagged [function-parameter]

The function parameters are the variable names, listed in the definition of the function.

In many programming languages, parameters are the essence of the functions. The function parameters define the variable names, listed in the definition of the function. They are often confused with (and referred to as) function arguments, which actually are the real values that are passed to and received by the function when it is being called.

314 questions
0
votes
2 answers

How to write a function type to access nested key of object in typescript

I'm trying to write a function that will accept 2 parameters i.e key and subkey and return one of the properties of that nested object. I have successfully written the type for function but cannot access the property for the same. This is what my…
Kunal Jain
  • 41
  • 4
0
votes
1 answer

Using purrr::possibly to catch dynamic error messages

I've written a custom function that does a number of checks and throws a different error when a check fails. Below is a simple example function that takes a data.frame and a column name and simply outputs the sum of that column. I'm using…
Rasul89
  • 588
  • 2
  • 5
  • 14
0
votes
1 answer

Funtions with two parameter not working in React

I have 2 files. One of them is "http" folder for requests, the other one is React Component. I have a problem when I want to change the form and upload a profile photo. Changing form is working (userDetails), but the photo object not working…
0
votes
1 answer

Typescript Error : Declaring a parameter as a union of interfaces. Instead of picking one of the choices, it picks all of them

This is the code I want to write interface InputField{ formHeading:string, isText:boolean, fields:any[] } interface InfoField{ formHeading:string, isText:boolean, textData:string[] } let testInfoField:…
0
votes
1 answer

How to hint users to do the allocation in out parameter?

Assum I have some pure C code like this. It is not the real code, just for an example. struct Param { struct InParam { int a; int b; } in; struct OutParam { int *c; } out; }; void MakeArray(struct Param *param) { // just for…
Xingx1
  • 127
  • 7
0
votes
1 answer

How to pass an empty span object?

Is there a way to pass an empty std::span to a function? I have a function like below: bool func( const std::vector& indices ) { if ( !indices.empty( ) ) { /* do something */ } ... } // when calling it with an…
digito_evo
  • 3,216
  • 2
  • 14
  • 42
0
votes
2 answers

Using Double Pointers in Memory Location

I'm trying to understand purpose and how it's works double pointer in this code. Why we use **p in the declaring function but inside the function we used *p? void allocate(int** p) { *p = (int*)malloc(sizeof(int)); } int main() { int *p =…
0
votes
0 answers

C++ Template function that accepts a function as parameter

I have a Component that I attach to projectiles spawned by my character. I would like to make a callback function that is called when the projectile hits a valid target. In Component.h I declare a function : template void…
0
votes
2 answers

Parameters KFunction in Kotlin

I have a class that has the type parameter KFunction<*> (It is understood that I will indicate the type of function that I want to work with in the future) I want a class method to take the same parameters that KFunction has and call subscribers…
Danila
  • 53
  • 6
0
votes
4 answers

Passing arrays as arguments in C

I'm trying to make a function that identifies the maximum value in an array and calculate the sum of each time it appears. That's fine but the problem is that I need to make the function args the size of the array and the array itself. This is what…
0
votes
2 answers

How to get original function parameter names in production webpack build

I'm trying to implement something similar to dependency injection, By getting parameter names from a function exposed by a javascript module, something like this: module.exports = (router,form,query,url) => { // Do something with these…
0
votes
1 answer

Unable to convert template arguments to match function arguments

I have 3 functions in a header file template const T &minD(T const& a, T const& b) { if (a > b) { return b; } else { return a; } } This is the objective function with which I am trying to match…
Abhishek Panjabi
  • 439
  • 4
  • 23
0
votes
2 answers

Android Kotlin - How do i set a default value for DialogInterface.OnClickListener as function parameter?

This is my function declaration: fun MyDialog(ctx: Context, msg: String, yestext: String = "", OnYes: DialogInterface.OnClickListener): AlertDialog How do i set a default value for "OnYes: DialogInterface.OnClickListener"? I have tried OnYes:…
Eddi
  • 479
  • 5
  • 22
0
votes
1 answer

Use a variable created inside a function as function parameter

Suppose you have the following code to define this simple function: def a(x,y,b): z=[x,y] c=b*2 return c I want to call this function with the value z[0] as input for parameter b. If I try to call the function in the following…
razorF
  • 11
  • 3
0
votes
2 answers

Passing Function as parameter in python

I am trying to make a function to calculate rolling mean or sum : def rolling_lag_creator(dataset,i,func): dataset['Bid']=dataset.loc[:,'Bid'].rolling(window=i).func() return dataset but this function is throwing error when i am calling…