How does this delegate work?
Given this delegate:
How this function return a
Generator
delegate?
8 Replies
Well,
NextInt
is a static field with the type Generator<int>
, and it's initialized with a lambda expression which matches the Generator<int>
delegate.This seems correct; I thought
NextInt
was a function and not a fieldIt doesn't have
()
so it's not a methodThis
NextInt
property is used here in what seems to be LINQ:
May I know how this is working?
NextInt
doesn't seem to be IEnumerable
That shouldn't work
This is an example from a book, so maybe the context will help? Will it really not work?
yeah no this doesn't make sense