Stream: helpdesk (published)

Topic: type weirdness


view this post on Zulip John Wise (Jul 27 2024 at 17:11):

(v1.11) julia> a::Real = 0
0

(v1.11) julia> a
0

(v1.11) julia> typeof(a)
Int64

?????

view this post on Zulip Mosè Giordano (Jul 27 2024 at 17:13):

Real is an abstract type, you can't have instances of abstract type. Maybe you want to elaborate on what you want to achieve

view this post on Zulip John Wise (Jul 27 2024 at 17:15):

Mosè Giordano said:

Real is an abstract type, you can't have instances of abstract type. Maybe you want to elaborate on what you want to achieve

Ah that explains it. Only instantiate with a concrete type.

view this post on Zulip Mason Protter (Jul 27 2024 at 18:06):

specifically,

julia> a::Real = 0
0

julia> a isa Real
true

holds.

view this post on Zulip Guido Kraemer (Jul 28 2024 at 08:12):

julia> Int <: Real
true

Int is a subtype of Real


Last updated: Nov 06 2024 at 04:40 UTC