Some Monkey syntax and language features
Monkey Archive Forums/Monkey Tutorials/Some Monkey syntax and language features| 
 | ||
| Here's a thingy I wrote to show off some of Monkey's syntax to others.  As you can see, the pygments parser/lexer for Monkey still needs some work.  I forgot who on the forums wrote it, but please check this file for maybe a few bugs that can be fixed! https://gist.github.com/nobuyukinyuu/7186162 | 
| 
 | ||
| A very handy piece of code to have for any beginner, well done Nobuyuki! | 
| 
 | ||
| Thank you! Very useful for begginers like me! | 
| 
 | ||
| Try/Catch/End(End Try)! | 
| 
 | ||
| This bits kinda bonkers that it works though! str = "Hello World!" str = str[-6 .. -1] Print str 'Prints "World" | 
| 
 | ||
| This looks wrong, shouldn't New have Self.myVal = t ? 'Generic class Class MyGeneric<T> Field myVal:T Method New(t:T) Self.myVal End Method Method WhatsMyVal:T() Return T End Method End Class | 
| 
 | ||
| Infact that whole class  needs some TLC, this is a working version: Class MyGeneric<T> Field myVal:T Method New(t:T) Self.myVal = t End Method Method WhatsMyVal:T() Return myVal End Method End Class | 
| 
 | ||
| you guys are right.  Looks like I wasn't paying close enough attention!  The gist has been updated. I'd make an example for the Try block, but unfortunately I can't think of a succinct example to utilize it. Might require making a couple throwable classes. |