Suppose I had the following method:
function character_information(name::String, age::Int32; c...)
println("Name: $name Age: $age")
c_values = values(c)
println(c_values.Alignment)
end
# We're not following D&D rules, so in my little game an intelligence
# level of 5 is considered high intelligence.
character_information("Queen Svetlana",25,Alignment="Chaotic Evil",Intelligence=5)
If I were to use typeof(c)
it will return Base.Iterators.Pairs{...}
. In the documentation it says:
Transforms an indexable container into an Dictionary-view of the same data.
If I were to use values(c)
I would get the namedtuple that contains all the keyword-values that I passed into the function. Using a keyword(c_values.Alignment
) I can access the associated value. Is that the correct way of accessing an individual value?