覆盖冒号()以连接头部和尾部

时间:2017-09-23 08:57:01

标签: julia

是否可以覆盖:以允许此头尾连接语法?

julia> (:){T}(a::T, b::Array{T}) = vcat([a], b)                   
Colon()         

julia> a=collect(2:9);

julia> 1:a      
ERROR: MethodError: no method matching colon(::Int64, ::Array{Int64,1})
Closest candidates are:          
  colon(::T<:Real, ::Any, !Matched::T<:Real) where T<:Real at range.jl:47
  colon(::A<:Real, ::Any, !Matched::C<:Real) where {A<:Real, C<:Real} at range.jl:14
  colon(::T, ::Any, !Matched::T) where T at range.jl:46           
  ...           

0 个答案:

没有答案