Skip to content

Instantly share code, notes, and snippets.

@squeedee
Created November 30, 2010 18:22
Show Gist options
  • Save squeedee/722117 to your computer and use it in GitHub Desktop.
Save squeedee/722117 to your computer and use it in GitHub Desktop.
package com.visfleet.core {
public function chance(numerator:int = 50, denominator:int = 100):Boolean {
var odds:Number = Number(numerator)/denominator;
return Math.random() <= odds;
}
}
package com.visfleet.core {
public function defaultIfNull(value:*,defaultValue:*):* {
if (value == null)
return defaultValue;
return value;
}
}
package com.visfleet.core {
public function defaultIfNullOrEmpty(value:*, defaultValue:*):* {
if (isNull(value))
return defaultValue;
if (value.toString() == "")
return defaultValue;
return value;
}
}
package com.visfleet.core {
public function isNotNull(value:*):Boolean {
return value != null;
}
}
package com.visfleet.core {
public function isNull(value:*):Boolean {
return value == null;
}
}
package com.visfleet.core {
public function isNullOrEmpty(value:*):Boolean {
return (value == null) || (value.toString() == "");
}
}
package com.visfleet.core {
public function times(repeat:uint):Array {
return new Array(repeat);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment