본문 바로가기
프로그래밍

메소드의 아름다움 에러

by it-view 2022. 2. 15.
반응형

도입

메서드 오류

hrthtrh()
UndefVarError: hrthtrh not defined
push!()
MethodError: no method matching push!()
Closest candidates are:
  push!(::AbstractChannel, ::Any) at /opt/julia-1.6.3/julia-1.6.3/share/julia/base/channels.jl:10
  push!(::Set, ::Any) at /opt/julia-1.6.3/julia-1.6.3/share/julia/base/set.jl:59
  push!(::Base.InvasiveLinkedListSynchronized{T}, ::T) where T at /opt/julia-1.6.3/julia-1.6.3/share/julia/base/task.jl:570
 
function printthisthang(x::Int64)
    println(x)
end
printthisthang(5.5)
MethodError: no method matching printthisthang(::Float64) Closest candidates are:   printthisthang(::Int64) at In[6]:1
mutable struct OurCollection
    x
        function OurCollection(x::Any ...)
        new(x)
    end
    end
    ```

    ```js
    z = OurCollection(5, 10, 15)
    z[2]
    MethodError: no method matching getindex(::OurCollection, ::Int64)
    ```

    ```js
    import Base: getindex
    getindex(x::OurCollection, i::Int64) = x.x[i]
    z[2]
    10
    ```

    <div class="content-ad"></div>

댓글