User:Ulti/sandbox: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Ulti
No edit summary
imported>Ulti
No edit summary
Line 1: Line 1:
{{User:Ulti/Nav|active=sandbox}}


   This page is a sandbox used for testing my code before putting it live elsewhere on the wiki
   This page is a sandbox used for testing my code before putting it live elsewhere on the wiki

Revision as of 03:18, 15 October 2014

  Ulti     Talk     My Contributions     My Sandbox     Nav Bar  
 This page is a sandbox used for testing my code before putting it live elsewhere on the wiki

migrating to ASH from PHP (work in progress)

ASH is basically half-ass Java because of feature limitations made specific for interacting with KoL.

Default Function Parameters

In PHP you can define default values for your arguments like so:

function helloWorld($msg='Hello world!')
{
	return $msg;
}
echo helloWorld();//prints "Hello world!" to the browser

In ASH, default parameters is accomplished like so:

string helloWorld(string msg)
{
	return msg;
}
string hellowWorld()
{
	string msg='Hello world!';
	return helloWorld(msg);
}
print(helloWorld());//prints "Hello world!" to kolmafia's command line interface.