JuliaLang/julia

Single argument `isa` function

Open

#32,018 opened on May 13, 2019

View on GitHub
 (15 comments) (15 reactions) (0 assignees)Julia (5,773 forks)batch import
featurehelp wanted

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (Avg merge 20d 6h) (157 merged PRs in 30d)

Description

It would be nice to have a single argument isa for cleaner filtering code.

filter(x -> !isa(x, AbstractFloat), [1, 2.0])
# could become
filter(!isa(AbstractFloat), [1, 2.0])

This would provide some consistency with other functions, such as isequal, but since isa is a builtin function, defining other variants doesn't seem trivial.

julia> Core.isa(::Type{T}) where {T} = (x) -> isa(x, T)
ERROR: cannot add methods to a builtin function

Contributor guide