x


Enumerators in Boo

Hi, I'm trying to create a simple enumerator in boo.

Unity returns the following.

 Ambiguous reference 'GetEnumerator': Lister.GetEnumerator(), Lister.GetEnumerator()


This is working code, according to the standalone boo interpreter, but Unity is messing up somewhere. How can I work around it?

 import UnityEngine
 import System.Collections
 
 class Lister (Generic.IEnumerable[of int]):
 
     public def GetEnumerator() as Generic.IEnumerator[of int]:
         yield 1
         yield 2
         yield 3
 
     def IEnumerable.GetEnumerator() as IEnumerator:
         return GetEnumerator()
 
 [ExecuteInEditMode]
 class Enumerable (MonoBehaviour):
 
     def Awake ():
         l = Lister()
         for i in l:
             Debug.Log("$i")
more ▼

asked Mar 19, 2012 at 10:41 AM

steinbitglis gravatar image

steinbitglis
429 43 44 51

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I worked around this, by creating a reference to GetEnumerator. As it appears, it did not cause infinite recursion.

 class Lister (Generic.IEnumerable[of int]):    
     public specificGetEnumerator = GetEnumerator
     public def GetEnumerator() as Generic.IEnumerator[of int]:
         yield 1
         yield 2
         yield 3        
     def IEnumerable.GetEnumerator() as IEnumerator:
         return specificGetEnumerator()
more ▼

answered Mar 20, 2012 at 06:13 PM

steinbitglis gravatar image

steinbitglis
429 43 44 51

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x132
x38
x7

asked: Mar 19, 2012 at 10:41 AM

Seen: 1046 times

Last Updated: Mar 20, 2012 at 06:23 PM