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 '12 at 10:41 AM

steinbitglis gravatar image

steinbitglis
384 14 17 23

(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 '12 at 06:13 PM

steinbitglis gravatar image

steinbitglis
384 14 17 23

(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:

x94
x27
x5

asked: Mar 19 '12 at 10:41 AM

Seen: 801 times

Last Updated: Mar 20 '12 at 06:23 PM