JuliaLang/julia

Single argument `isa` function

Open

#32,018 创建于 2019年5月13日

在 GitHub 查看
 (15 评论) (15 反应) (0 负责人)Julia (5,773 fork)batch import
featurehelp wanted

仓库指标

Star
 (48,709 star)
PR 合并指标
 (平均合并 20天 6小时) (30 天内合并 157 个 PR)

描述

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

贡献者指南