Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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:






# Julia program to illustrate 
# the use of getfield() method
   
# Getting the extracted named field
# from the specified value of composite type. 
a = 5//2
println(getfield(a, :num))

Output:

5

Example 2:




# Julia program to illustrate 
# the use of getfield() method
   
# Getting the extracted named field
# from the specified value of composite type. 
a = 7//3
println(getfield(a, :num))

Output:

7
My Personal Notes arrow_drop_up
Recommended Articles
Page :