Difference between revisions of "User:Ulti/sandbox"

From Kolmafia
Jump to navigation Jump to search
imported>Ulti
(A page for testing my code before putting it live)
 
imported>Ulti
Line 1: Line 1:
 
A page for testing my code before putting it live
 
A page for testing my code before putting it live
 +
==migrating to ASH from PHP (work in progress)==
 +
ASH is basically half-ass Java because of feature limitations made specific for interacting with KoL.<br>
 +
===Default Function Parameters===
 +
In PHP you can define default values for your arguments like so:
 +
<pre>
 +
function helloWorld($msg='Hello world!')
 +
{
 +
return $msg;
 +
}
 +
echo helloWorld();//prints "Hello world!" to the browser
 +
</pre>
 +
In ASH, default parameters is accomplished like so:
 +
<pre>
 +
string helloWorld(string msg)
 +
{
 +
return msg;
 +
}
 +
string hellowWorld()
 +
{
 +
string msg='Hello world!';
 +
return helloWorld(msg);
 +
}
 +
print(helloWorld());//prints "Hello world!" to ash's command line.
 +
</pre>

Revision as of 02:34, 15 October 2014

A page for testing my code before putting it live

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 ash's command line.