-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from 01010111/dev
Dev
- Loading branch information
Showing
19 changed files
with
949 additions
and
678 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import zero.utilities.Vec2; | ||
|
||
class Main { | ||
public static function main() { | ||
trace('howdy world'); | ||
|
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package zero.extensions; | ||
|
||
using zero.extensions.EnumExt; | ||
using zero.extensions.ArrayExt; | ||
|
||
/** | ||
* A collection of extension methods for Enums | ||
* | ||
* **Usage:** | ||
* | ||
* - use this extension by adding this where you normally import modules: `using zero.extensions.EnumExt;` | ||
* - now you can use any of these functions on different arrays: `MyEnum.get_random();` | ||
* - or use all of the extensions in this library by adding: `using zero.extensions.Tools;` | ||
*/ | ||
|
||
class EnumExt | ||
{ | ||
|
||
/** | ||
* Get an array of all enums, shortcut for Type.allEnums() | ||
* @param e input | ||
* @return Array<T> return [for (e in Type.allEnums(e)) e] | ||
*/ | ||
public static inline function all<T>(e:Enum<T>):Array<T> return [for (e in Type.allEnums(e)) e]; | ||
|
||
/** | ||
* Returns a random enum value from input | ||
* @param e input | ||
* @return T return e.all().get_random() | ||
*/ | ||
public static inline function get_random<T>(e:Enum<T>):T return e.all().get_random(); | ||
|
||
} |
Oops, something went wrong.