[Gambas-user] IIf syntax

Emil Lenngren emil.lenngren at ...626...
Fri Mar 16 19:20:27 CET 2012


Hi. I wonder if this syntax is intended to be allowed ;)

Public Function f1()
  Print "f1!"
End

Public Function f2()
  Print "f2!"
End

Public Sub Main()
  IIf(True, f1, f2)()
End

It prints out "f1!" ...

But in this code:
Public Function f1(a As Integer)
End

Public Function f2(a As String)
  a = "a string"     'Line 5
End

Public Sub Main()
  Dim i As Integer
  For i = -1 To 0
    IIf(i, f1, f2)(1)
  Next
End

I get this message: MMain.f2.5: #6: Type mismatch: wanted Integer, got
String instead
Which is weird because isn't the a argument of type String? ;)

/Emil



More information about the User mailing list