Updating data by Array like setter #[]= #94
heronshoes
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
(This topic has moved from issue #43 )
Arrow data is immutable. So it is difficult to updating data like an Array.
I want to write
vector[index]=value
in RedAmber, I defined#[]=
method and triedvector.[]=(index, value)
, but didn't work well. It always returns value as a left side value invector[index]=value
.I implemented
#replace(index, value)
in current Vector and it returns reference to the updated object. But this is not ruby-like style.Arroeのデータはイミュータブルなので、通常のArrayのように値を更新できません。
RedAmberでも
vector[index]=value
のように書きたくて、#[]=
メソッドを定義してvector.[]=(index, value)
のようにしてみるのですがうまく動きません。結果はvector[index]=value
の左側が帰ってきます。現在は値の更新は
#replace(index, value)
でやっていますが、らしくない書き方なので良い方法があればいいなと思っています。Beta Was this translation helpful? Give feedback.
All reactions