Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How to access the end index of an array as attribute of a class

$
0
0

@QUANG_VU_NGUY_N_PH_M wrote:

struct Test
    data::Vector{Int}
end

Base.getindex(test::Test, index) = test.data[index]

Then, to get idex:

test = Test([1,2,3])

I can get:

test[1]
test[2]

How to get the last index value
test[end] didnot work.

Thank you for reading my question

Posts: 6

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles