Wednesday 16 March 2016

Julia: BoundsError


BoundsError thrown, when you try to access an out-of-bounds element.
julia> msg="Hello World"
"Hello World"

julia> msg[end+1]
ERROR: BoundsError: attempt to access 11-element Array{UInt8,1}:
 0x48
 0x65
 0x6c
 0x6c
 0x6f
 0x20
 0x57
 0x6f
 0x72
 0x6c
 0x64
  at index [12]
 in getindex at /Applications/Julia-0.4.1.app/Contents/Resources/julia/lib/julia/sys.dylib

julia> msg[0]
ERROR: BoundsError: attempt to access 11-element Array{UInt8,1}:
 0x48
 0x65
 0x6c
 0x6c
 0x6f
 0x20
 0x57
 0x6f
 0x72
 0x6c
 0x64
  at index [0]
 in getindex at /Applications/Julia-0.4.1.app/Contents/Resources/julia/lib/julia/sys.dylib



Previous                                                 Next                                                 Home

No comments:

Post a Comment