# Using parameters inside a function

**URL:** https://discourse.julialang.org/t/using-parameters-inside-a-function/92004
**Category:** General Usage
**Tags:** parametersjl
**Created:** [December 22, 2022, 1:53pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004 "2022-12-22T13:53:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dgagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgagnon/32/45466_2.png) [@dgagnon](https://discourse.julialang.org/u/dgagnon)
#### Post date: [December 22, 2022, 1:53pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004/1 "2022-12-22T13:53:18Z")

</div>

Hello

I want to use a function using parameters.jl. Inside REPL I simply type:

```julia
julia> called_function(param1=4, param2=0)

```

The function “called\_function” has other parameters but those have default values which are good enough for me.  
However I want to create a wrapper that will take some arguments and transfer them to the called function:

```julia
function my_function( a::Int64, b::Int64, other arguments)
    ...
    called_function(a, b) # <= How can I say that 'a' is for param1 and 'b' for param2?
    ...
end

```

I get an error like this:

```julia
ERROR: MethodError: no method matching called_function(::Int64, ::Int64)

```

If I specify the 4 arguments of “called\_function” I don’t need to state the name of the parameters:

```julia
called_function(4, 0, UUID("51d35f80-81ee-11ed-1a59-6be8ccc438a2"), [])

```

My fallback plan is of course to state all parameters within “my\_function”. I nevertheless would like to know how I can work around this and use default values.

Thants for your help.

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [December 22, 2022, 2:09pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004/2 "2022-12-22T14:09:17Z")

</div>

Maybe `called_function(param1=a, param2=b)`?

If that doesn’t work, please post a complete, minimal example that shows the problem.

---

<div class="post-metadata">

### Author: ![dgagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgagnon/32/45466_2.png) [@dgagnon](https://discourse.julialang.org/u/dgagnon)
#### Post date: [December 22, 2022, 2:22pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004/3 "2022-12-22T14:22:53Z")

</div>

Does not work. I get the same message.  
Here’s a complete example with the used package:

```julia
Pkg.add(url="https://github.com/anyonlabs/Snowflake.jl", rev="main")
using Snowflake
function my_function(a::Int64, b::Int64)
    c = QuantumCircuit(qubit_count=a, bit_count=b)
end

julia> my_function(2,0)
ERROR: MethodError: no method matching my_function(::Int64, ::Int64)
Closest candidates are:
  my_function(::Int64, ::Int64, ::Int64) at REPL[83]:1
Stacktrace:
 [1] top-level scope
   @ REPL[84]:1

```

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [December 22, 2022, 2:43pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004/4 "2022-12-22T14:43:24Z")

</div>

Your example works for me:

```julia
julia> my_function(2,0)
Quantum Circuit Object:
   id: c6f6da90-8206-11ed-1053-3bc9d78927f5 
   qubit_count: 2 
   bit_count: 0 
q[1]:
     
q[2]:

```

The error message you have doesn’t make sense with the code, maybe try to run it all again?

---

<div class="post-metadata">

### Author: ![dgagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgagnon/32/45466_2.png) [@dgagnon](https://discourse.julialang.org/u/dgagnon)
#### Post date: [December 22, 2022, 2:51pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004/5 "2022-12-22T14:51:58Z")

</div>

@sijo

damn it! What did I do wrong? I’ll find out… eventually.

Thanks Sijo
