Extract a named field in Julia – getfield() Method
Last Updated :
01 Apr, 2020
The getfield()
is an inbuilt function in julia which is used to extract a named field from the specified value of composite type.
Syntax:
getfield(value, name::Symbol)
Parameters:
- value: Specified value of composite type.
- name::Symbol: Specified symbol.
Returns: It returns the extracted named field from the specified value of composite type.
Example 1:
a = 5 / / 2
println(getfield(a, :num))
|
Output:
5
Example 2:
a = 7 / / 3
println(getfield(a, :num))
|
Output:
7
Share your thoughts in the comments
Please Login to comment...