In Julia, you can define a Function inside another function.
julia> function arithmetic(a, b)
function sum(a ,b)
a+b
end
function subtract(a, b)
a-b
end
function mul(a, b)
a*b
end
function div(a, b)
a/b
end
r1 = sum(a, b), subtract(a, b), mul(a,b), div(a,b)
end
arithmetic (generic function with 1 method)
julia> addition, subtraction, multiplication, division = arithmetic(20, 10)
(30,10,200,2.0)
julia> addition
30
julia> subtraction
10
julia> multiplication
200
julia> division
2.0
This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here