I'd like to do this, but I wonder how it should work. There are mainly 2 ways:
1) Get the index of the first matching element, or -1 if not found. This would be consistent with the non-block usage, but different from GolfScript, and still longer if you actually want the value.
2) Get the value of the first matching element, like GolfScript. In that case, what should happen if there's no match? I don't like how GolfScript just "returns void". Also, what if you wanted the index?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
= is not implemented for ArrayList-Block, so you could use # for option 1 and = for option 2.
Returning void is probably the best choice for option 2, in case you're building an array of matches for several different conditions. The only unambiguous alternative would be the array itself, but I doubt that would be useful.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to do this, but I wonder how it should work. There are mainly 2 ways:
1) Get the index of the first matching element, or -1 if not found. This would be consistent with the non-block usage, but different from GolfScript, and still longer if you actually want the value.
2) Get the value of the first matching element, like GolfScript. In that case, what should happen if there's no match? I don't like how GolfScript just "returns void". Also, what if you wanted the index?
=
is not implemented for ArrayList-Block, so you could use#
for option 1 and=
for option 2.Returning void is probably the best choice for option 2, in case you're building an array of matches for several different conditions. The only unambiguous alternative would be the array itself, but I doubt that would be useful.
That's a great idea! I think I'll do that.
Done, will be released in 0.6.2