Arrays as inputs

Monkey Forums/Monkey Programming/Arrays as inputs

Tibit(Posted 2013) [#1]
This works:
	Local test:SpecificationHandler = New SpecificationHandler()
	Local requirements:IClassParser[2]
	requirements[0] = New ClassEndsWith("Run")
	requirements[1] = New ClassBeginsWith("Run")
	test.TestFilter(New AllClassesThat(requirements), New MethodBeginsWith("Test"), New PrintLog)


This does not, compile error.
	Local test:SpecificationHandler = New SpecificationHandler()
	test.TestFilter(New AllClassesThat([New ClassEndsWith("Run"), New ClassBeginsWith("Run")]), New MethodBeginsWith("Test"), New PrintLog)


We addressed something similar before, but is the error on the second example really needed?


Jesse(Posted 2013) [#2]
what kind of error?

this one works:
Strict
Function Main:Int()

	Local a:beta = New beta([New alpha(2,7),New alpha(6,5)],[New alpha(20,30),New alpha(550,1000)])
	a.display()
	Return 1
End Function

Class alpha
	Field d:Int = 3
	Field f:Int = 4
	
	Method New(d:Int, f:Int)
		Self.d = d
		Self.f = f
	End Method
End Class

Class beta
	Field a1:alpha[]
	Field b1:alpha[]
	Method New(a:alpha[],b:alpha[])
		a1 = a
		b1 = b
	End Method
	
	Method display:Void()
		Print a1[0].d
		Print a1[0].f
		Print b1[0].d
		Print b1[0].f
		Print a1[1].d
		Print a1[1].f
		Print b1[1].d
		Print b1[1].f
		
		
	End Method
	
End Class


Monkey 67b

.


Tibit(Posted 2013) [#3]
I did the same, with the exception that the classes added where using the same interface, but where not of the same core type.