Skip to content

Instantly share code, notes, and snippets.

@zachwlewis
Created May 23, 2013 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachwlewis/5637329 to your computer and use it in GitHub Desktop.
Save zachwlewis/5637329 to your computer and use it in GitHub Desktop.
A simple class containing protected variables, getters and setters, and optional arguments.
public class Foo extends Object
{
// Variables
protected var _bar:String;
/** Contains a user-set string or "foo". Will never be blank. */
public function get bar():String { return _bar; }
public function set bar(value:String)
{
if (value != "")
{
_bar = value;
}
else
{
_bar = "foo";
}
}
/** Constructor */
public function Foo(s:String = "foo")
{
_bar = s;
}
/**
* Appends a string to the Foo's bar and returns the new string.
* @param s The string to append to the Foo's bar.
* @return A new string containing the Foo's bar and s.
*/
public function appendString(s:String):String
{
var appendedString:String;
appendedString = _bar + s;
return appendedString;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment