I'm a bit confused about the Perl OO syntax. From my reading "foreach" acts as an iterator.
Any somebody tell me in the standard example below:
- how to count the total number of $query->answer
- how to access the i'th answer; $query->answer[$i] does not work
- how to access a random answer
thanks
gtoomey
--
use Net::DNS;
my $res = Net::DNS::Resolver->new;
my $query = $res->query("example.com", "NS");
Re: IEnumerable is strange ... That's exactly what 'yield return' is: ...int foo()... and similarly investigate how foreach is ... The function implementing the iterator is technically never entered. ... (microsoft.public.dotnet.languages.csharp)
Re: comparison of objects ... the standard function is being used versus your redefinition. ... User's interface would give means to iteration, ... ** User and implementor interface:... An iterable is an object for which an iterator can be defined. ... (comp.lang.lisp)
Re: recursive GetEnumerator() ... it couldn't do that - don't forget that foreach could be in one ... The way I implemented it before in c was to pass a function to the iterator,... I gues if the type isnt completly fixed at compile time this isnt possible ... There's a big difference between Reflector and reflection... ... (microsoft.public.dotnet.languages.csharp)
Re: Erase in a map ... According to the standard, map::erase does return nothing, whereas, say, ... returning an iterator as a conforming extension, ... vector::erase on the other hand invalidates...erase() method does return an iterator). ... (microsoft.public.vc.stl)
Re: Features new to Java 5.0 rated today ... But would it not be useful if the foreach statement could go over an ... But what if the Iterator had been used previous to being passed to the ... If you're not thinking about the entering state of a Collection before ... puting it into a foreach statement you're.... ... (comp.lang.java.advocacy)