Single-line discrepancy.
Monkey Forums/Monkey Programming/Single-line discrepancy.
| ||
I have code that looks something like this. [monkeycode] Class IMyInterface Method SetSomething:Void(x:Int, y:Int) Method DoSomething:Void() End Class MyComponent Implements IMyInterface Field x:Int, y:Int Method SetSomething(x:Int, y:Int) Self.x = x Self.y = y End Method DoSomething:Void() Print "Did something." End End Class MyClass Implements IMyInterface Field component:MyComponent 'works fine Method SetSomething:Void(x:Int, y:Int) component.SetSomething(x, y) End 'doesn't work unless it is written in block form Method DoSomething:Void() component.DoSomething() End End [/monkeycode] I get this error: Syntax error - unexpected token ')' I can avoid it by not putting the parameter-less methods on one line, but it seems silly. EDIT: It also works if I add a semicolon like so: [monkeycode] Class MyClass Implements IMyInterface '... Method DoSomething:Void() component.DoSomething(); End End [/monkeycode] It's still silly. |
| ||
If you want it to be consistent you need to add a semi-colons between the code as shown below.Class MyClass Implements IMyInterface '... Method SetSomething:Void(x:Int, y:Int); component.SetSomething(x, y); End Method DoSomething:Void(); component.DoSomething(); End End |
| ||
Yes, I arrived at the same place and was just editing my post. Thank you for your quick response anyhow. |
| ||
Maybe we can use this thread to discuss the weather? It's very cloudy here. |
| ||
Its boiling where I am. It seems weird seeing semicolons in a BASIC like language. |
| ||
Are semicolons official? I hadn't realised that was an option, so I have been using blocks always. I don't think it's silly - in a Basic-like language the compiler is always likely to be limited in how much it can understand without newline cues. It is no sillier than having to put semicolons on the end of every single-statement line in C. Edit: I see it's in the official Monkey documentation. |
| ||
Nice grammatically incorrect but contextually correct semicolon. Its like a grammar pun! Edit: Why did you edit it out! |