# Returs the value of a variable

**URL:** <https://discourse.julialang.org/t/returs-the-value-of-a-variable/95487>\
**Category:** Performance\
**Tags:** question\
**Created:** [March 3, 2023, 8:44am UTC](https://discourse.julialang.org/t/returs-the-value-of-a-variable/95487 "2023-03-03T08:44:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amine](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Amine](https://discourse.julialang.org/u/Amine)\
**Post date:** [March 3, 2023, 8:44am UTC](https://discourse.julialang.org/t/returs-the-value-of-a-variable/95487/1 "2023-03-03T08:44:10Z")

</div>

Hey guys,

I am havijg small trouble with my script if you can help, I have a function that calculates angles and i want to use one of these angles “θtT” as an argument of this same function in the second par of my code but when i want to return it’s value to use it i get the folllowing error :  
“ERROR: MethodError: no method matching Snell\_Descartes(::Type{Nothing}, ::Main.Reflexion\_Transmission.solide, ::Main.Reflexion\_Transmission.fluide)”

The error indicates that my argument has the wrong type i think but i can’t figure the solution out. Here’s my function :

function Snell\_Descartes(θ::Number,mil1::fluide, mil2::solide)  
θ=θ/180_π  
θrL=real(asin(mil1.VL/mil1.VL_sin(θ)))

```
θtL=π/2
try
    θtL=real(asin(mil2.VL/mil1.VL*sin(θ)))
catch y
    return NaN
end
θtT=π/2 
try
    θtT=real(asin(mil2.VT/mil1.VL*sin(θ)))
catch y

end

println("")
println("θ incident = ",round(θ/π*180; digits =2))
println("θrL = ",round(θrL/π*180; digits =2))
println("θtL = ",round(θtL/π*180; digits =2))
println("θtT = ",round(θtT/π*180; digits =2))
#display
xi=-1:0.01:0
xrt=0:0.01:1

p=plot_SD_base(xi, xrt, θ, θrL, θtL, mil1, mil2)
plot!(xrt*sin(θtT),-xrt.*cos(θtT),lw=3,label="tᵀ")
annotate!(xrt[end]*sin(θtT), -xrt[end].*cos(θtT), text("tᵀ", :black, :right, 14))

display(p)
#savefig(p,"Snell_Descartes.png")
return θtT

```

end

Thank you for you help !

---

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [March 3, 2023, 9:24am UTC](https://discourse.julialang.org/t/returs-the-value-of-a-variable/95487/2 "2023-03-03T09:24:12Z")

</div>

I think that you’re calling your function with the first argument being of type `Nothing`, but your function restricts the first argument to be a number. The second two arguments are fine, but this is a problem with how you are calling the function, not the function itself.
