# Returs the value of a variable

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 !

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.

1 Like