Skip to content
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

PYP last qn #594

Open
danyelys opened this issue Apr 27, 2022 · 7 comments
Open

PYP last qn #594

danyelys opened this issue Apr 27, 2022 · 7 comments

Comments

@danyelys
Copy link

hi anyone knows why this wont compile?
Screenshot (162)

@mingshan2705
Copy link

mingshan2705 commented Apr 27, 2022

I might be wrong but I think the "this" in line 24 refers to the MyStream in line 22, and this.get() in line 22 will return an object of type R which causes an error since fn expects a type T object (?) maybe you can try replacing "this" with "MyStream.this" in line 24 and see if it compiles

@danyelys
Copy link
Author

@mingshan2705 it works now with that. dint see that too HAHAH thank you!!

@danyelys
Copy link
Author

@mingshan2705 how does MyStream.this know which MyStream it is pointing to

@Swagston20
Copy link

u need the MyStream or else it wil run recursively with the R get()

@mingshan2705
Copy link

@mingshan2705 how does MyStream.this know which MyStream it is pointing to

Im not really sure also HAHA but something similar was discussed in recitation 7 qn 2.. maybe you can check that out

@shotnothing
Copy link

Yeah it doesn't really make logical sense as qualified this is a non-generic context, meaning its just something you need to remember that you can do.

https://docs.oracle.com/javase/specs/jls/se10/html/jls-15.html#jls-15.8.4

@DikshantDulal
Copy link

This is the same issue as in recitation 07, q2b) as pointed out above. You run into a recursive loop when you this.get() because it's calling the get method of your global MyStream instead of the local MyStream which is what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants