Re:Java 8’s new Optional type doesn't solve anything
by steveklabnik on Monday October 26, 2015 @02:59PM
(#10453603)
I have an open PR with documentation for just Iterator alone that has a diff so big github can't expand it. Hope they help.
Re:Java 8’s new Optional type doesn't solve anything
by kibwen on Monday October 26, 2015 @03:52PM
(#10453959)
Note that anytime you see a closure in any language that just takes a single argument, calls a single function with that argument, and returns the value of that function, then you can eliminate the closure entirely by just passing the function instead.
So `filter_map(|x| foo(x))` can be written more simply as just `filter_map(foo)`.
Re:Java 8’s new Optional type doesn't solve anything
by valarauca1 on Tuesday October 27, 2015 @07:38AM
(#10457368)
I know this but I can never get my code to compile when doing this. I always seem to get huge type errors even when I know the code is correct.
map(|x|foo(x)) //clean compile
map(foo) //type error
The number of times I've had this happen has just lead to me giving up on simply just passing the lambda as a variable instead of wrapping it in another.
Re:Java 8’s new Optional type doesn't solve anything
by kibwen on Tuesday October 27, 2015 @02:16PM
(#10460007)
Curious. Can you provide a full code example so that I can try to determine what's causing that error?
Re:Java 8’s new Optional type doesn't solve anything
by Manishearth on Wednesday October 28, 2015 @02:20AM
(#10463077)
Usually in these cases the culprit is autoderef/deref coercions.
Re:Java 8’s new Optional type doesn't solve anything
by kibwen on Thursday October 29, 2015 @12:01PM
(#10472046)
I don't see anything in `|x| foo(x)` that could be causing `x` to be deref'd.
Re:Java 8’s new Optional type doesn't solve anything
by Manishearth on Friday October 30, 2015 @03:34AM
(#10476545)
A deref coercion can happen there
Re:Java 8’s new Optional type doesn't solve anything
by valarauca1 on Tuesday October 27, 2015 @06:46PM
(#10461731)
Just make an issue?
Thanks :D
I've been really struggling to get iterators in rust. I don't have a very strong functional background :|