문제

Io allows an optional parameter referring to the index of a list item. How do I use that to refer to the list being mapped, for example, I could write:

testList := list(1,2,3,4)
testList map(i,v, if(testList(i+v), v, v-1))

and the result would be list(1,2,3,3)

But what if I want to write that without creating the variable testList? How do I refer to the list that I'm mapping?

도움이 되었습니까?

해결책

Without using an intermediate name, you cannot access the receiver inside the map. The map is evaluated within the context of the caller, i.e., where your call to list(1,2,3,4) would be made.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top