# An Observable of an abstract type

**URL:** <https://discourse.julialang.org/t/an-observable-of-an-abstract-type/25865>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 30, 2019, 6:01pm UTC](https://discourse.julialang.org/t/an-observable-of-an-abstract-type/25865 "2019-06-30T18:01:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 30, 2019, 6:01pm UTC](https://discourse.julialang.org/t/an-observable-of-an-abstract-type/25865/1 "2019-06-30T18:01:39Z")

</div>

I have an `Observable` (from [https://github.com/JuliaGizmos/Observables.jl](https://github.com/JuliaGizmos/Observables.jl)) that could contain any concrete subtype of some common abstract type. Is this the best way to do it?

```julia
using Observables
o = Observable(Any[])
o[] = [1] # update with an Int <: Real
o[] = [1.1] # update with a Float64 <: Real

```

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 30, 2019, 8:42pm UTC](https://discourse.julialang.org/t/an-observable-of-an-abstract-type/25865/2 "2019-06-30T20:42:25Z")

</div>

@pfitzseb answered on slack#gizmos:

```julia
using Observables
o = Observable{Real}(1)
o[] = 1 # update with an Int <: Real
o[] = 1.1 # update with a Float64 <: Real

```
