#JuliaTipOfTheDay #JuliaBeginners
2022-11-28
Say you define a type
```
struct Point2D
x::Int
y::Int
end
```
then x and y are the "fields" of this struct. `fieldnames(Point2D)` returns `(:x, :y)`.
If you define `mypt = Point2D(4, 8)`, then
`mypt.x` calls `getproperty(mypt, :x)` (see prev. post),
which by default calls `getfield(mypt, :x)`,
which is automatically defined by #JuliaLang to return `x`'s value.
(contd. from previous: https://julialang.social/@Sundar/109411842573985228
as part 2 of #FieldsAndProperties)
#juliatipoftheday #juliabeginners #julialang #fieldsandproperties