Create a field `cols` with an `operator fun set` a...
# getting-started
k
Create a field
cols
with an
operator fun set
and you can do
M.cols[3] = v
.
h
I have a cols field which returns a list of the column vectors
i've never thought it possible to write operator overload functions for individual fields
that's possible?
I thought a fields set operator had to have a parameter of the precise type as the type of the field's declaration
k
No you can't, you need an extra class and instance for this.
h
i figured
so i'd need to create a Rows class and a Cols class, essentially
k
Yes.
h
alright, doable
k
I'm not sure which one the JVM is best at inlining away, a permanent field or a new instance returned every time from the
cols
getter.
Something to benchmark.
h
yeah, you either have to add stuff to constantly update the permanent field or it's expensive to access it every time
k
You don't need to update anything.
h
i can use an inner class
it'll just store pointers basically
k
Yes.