isa(eltype(X), T) versus iseltype(X, T)

153 views
Skip to first unread message

Júlio Hoffimann

unread,
Mar 6, 2015, 1:09:32 AM3/6/15
to julia...@googlegroups.com
Hi,

Someone could please explain the difference?

julia> iseltype(Array(Int,1), Integer)
true

julia> isa(eltype(Array(Int,1)),Integer)
false

Thanks,
Júlio.

Mauro

unread,
Mar 6, 2015, 1:35:56 AM3/6/15
to julia...@googlegroups.com
Consider

julia> eltype(Array(Int,1))<:Integer
true

julia> isa(5, Number)
true

julia> isa(Int, Number)
false

julia> isa(Int, DataType)
true

isa tests whether something is an instance of a type. As Int is not an
instance of Integer but a subtype isa(Int,Integer)==false.

Júlio Hoffimann

unread,
Mar 6, 2015, 1:48:14 AM3/6/15
to julia...@googlegroups.com
Thank you Mauro.

-Júlio
Reply all
Reply to author
Forward
0 new messages