# Isdefined function in Julia

**URL:** <https://discourse.julialang.org/t/isdefined-function-in-julia/26045>\
**Category:** General Usage\
**Created:** [July 5, 2019, 3:55pm UTC](https://discourse.julialang.org/t/isdefined-function-in-julia/26045 "2019-07-05T15:55:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [July 5, 2019, 3:55pm UTC](https://discourse.julialang.org/t/isdefined-function-in-julia/26045/1 "2019-07-05T15:55:22Z")

</div>

Hi, the following is the code from OpenStreetMapX GitHub, which confused me.  
`extract_highways(ways::Vector{OpenStreetMapX.Way}) = [way for way in ways if isdefined(way, :tags) && haskey(way.tags, "highway")]`

After searching for help in REPL, I think the `isdefined` function here is like  
`isdefined(object, s::Symbol)`, so, it is used to test whether an assignable location is defined or not. The arguments here are a composite object and a field name (as a symbol). My question is, what is exactly “an assignable location is defined or not”? Does it mean the field is initialised or not?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [July 5, 2019, 4:11pm UTC](https://discourse.julialang.org/t/isdefined-function-in-julia/26045/2 "2019-07-05T16:11:58Z")

</div>

It basically means whether getfield will error or not

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [July 5, 2019, 4:13pm UTC](https://discourse.julialang.org/t/isdefined-function-in-julia/26045/3 "2019-07-05T16:13:16Z")

</div>

Thanks!
