November 2017
Beginner
316 pages
6h 40m
English
Reflection actually provides you with the ability to manipulate the attributes of an object at runtime. So whenever we create a function in Julia, we can ask some basic things about it, such as how many arguments does that function have, or more likely, what are the methods of that function available in the current scope, and so on.
To understand better, have a look at this code snippet, which creates a function and then tries to ask some questions about its properties:
# the first method tries to take in all integer values julia> function calculate_quad(a::Int64,b::Int64,c::Int64,x::Int64) return a*x^2 + b*x + c end calculate_quad (generic function with 2 methods) julia> calculate_quad(1,2,3,4) 27 # the second method ...
Read now
Unlock full access