Last active
March 1, 2016 21:38
-
-
Save jeremyheiler/fd84ca3985003bde4c63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a pony program that will print the first arg provided to the program. | |
// Every pony program requires an actor called "Main" | |
actor Main | |
// This is a constructor for the Main actor named "create". | |
// It is a convention (supported by syntactic sugar) to call constructors "create". | |
// In general, a constructor can have any name that begins with a lower case character. | |
// However, the Main actor requires its constructor to be called "create". | |
// The "=>" denotes the beginning of the constructor body. | |
new create(env: Env) => | |
// This is a try block. It means an exception can be thrown. | |
// The compiler reqires you to decide if you want to handle or pass on the exception. | |
// This program handles the exception. | |
try | |
// The "env" variable reprents the current environment. | |
// The "out" field represents standard out. | |
// The "print" method will print the argument and a new line. | |
env.out.print( | |
// The "args" field is an array of strings: Array[String]. | |
// The argument is requesting the String at the idnex 1. | |
// This is sugary for "env.args.apply(1)". | |
// An exception could be thrown if the provided index is out of bounds. | |
env.args(1) | |
) | |
// This block of code is executed when an exception is thrown in the try block. | |
else | |
// This prints the literal string "oops". | |
env.out.print("oops") | |
// This ends the "try" block. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment