-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock Q4b #600
Comments
Oops so sorry the image turned out to be a bit small |
MyStream should be in the bracket? |
hi, hmm can you check your return value ... MyStream.mapper <<< the dot there w the mapper is kinda wrong already.. ? unless you do have a property called mapper. 1) you realised you have to return a new stream , 2) you realised you need to override the get method. 3) you don't have a seed property/var and your get method has to be overridden. The only way you can complete your get method of this new stream is through your enclosing class (MyStreamT)'s get. And to do so, you need to use MyStream.this.get() to retrieve the enclosing value because, your current this refers to the MyStreamR |
hii, i'm not sure if this is correct but this is mine!
|
Like @pohja1999 said, MyStream.mapper does not exist. MyStream is an abstract class, so you should override the get() method anonymously, else your this.get() means nothing . Also I don't think you strictly need to for this question, but it might be good to use PECS as boilerplate i.e. Function<? super T, ? extends R> |
Hmm, i think this works too in this scenario since your get method now points to the new Stream's get() which is now an overridden version of the original abstract class's version and since the concrete class can never be created without a defined get method. Im kinda curious too on what test cases can be used to differentiate these two methods. What is the difference between returning a new Stream () with an overridden get method (with the applied function) and just returning a new stream of the new supplier. |
MyStream map(Function<? super T, ? extends U> mapper){ |
I think they are fundamentally the same code. Case 1:
Subbing
Focusing on the return and subbing
Resolving the supplier .get()
Case 2:
Focusing on the return and subbing
I think that they both resolve into MyStream objects with the exact same get(), and that I think there are fundamentally no differences or ways of distinguishing the two. I think the latter is just a more logically straightforward, possibly(?) less time complex way of generating the solution, while the former is easier to read and understand. |
Hi, is anyone able to help explain why my code doesn't work and if anyone has an elegant answer for this question!
Appreciate the help!
The text was updated successfully, but these errors were encountered: