createHashMapObject: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Some wiki formatting) |
mNo edit summary |
||
Line 10: | Line 10: | ||
|descr= Create a [[HashMap]] with an {{Link|https://en.wikipedia.org/wiki/Object-oriented_programming|Object-Oriented Programming}} behaviour. | |descr= Create a [[HashMap]] with an {{Link|https://en.wikipedia.org/wiki/Object-oriented_programming|Object-Oriented Programming}} behaviour. | ||
|s1= [[createHashMapObject]] details | |s1= [[createHashMapObject]] [details(, constructorArguments)] | ||
|p1= details: [[Array]] of [[Array]]s in format [name, value]. | |p1= details: [[Array]] of [[Array]]s in format [name, value]. | ||
Line 45: | Line 45: | ||
|seealso= [[call]] [[createHashMap]] | |seealso= [[call]] [[createHashMap]] | ||
}} | |p2=constructorArguments: [[Any]] - Arguments passed to _this in constructor (if a constructor exists)}} |
Revision as of 12:03, 10 May 2023
Description
- Description:
- Create a HashMap with an Object-Oriented Programming behaviour.
- Groups:
- HashMap
Syntax
- Syntax:
- createHashMapObject [details(, constructorArguments)]
- Parameters:
- details: Array of Arrays in format [name, value].
name can be anything like any other HashMap, but it must be a String for it to be used like an OOP object method (see call - Syntax 3).
Some special values, starting with #, are reserved and expect a specific value type (they are all optional):- "#create": Code - this is the hashmap object's constructor
- "#clone": Code - this is code happening when cloning is done on this hashmap object
- "#delete": Code - this is the hashmap object's destructor
- "#str": Code - code that is used to evaluate what is displayed when - must return String
- "#flags": Array of Strings - case-insensitive flags regarding this hashmap object
- "noCopy": forbids copying, +_hashMapObject will throw an error
- "sealed": prevents from adding and removing any keys - key values can still be edited
- "unscheduled": all methods (including #clone and #create) will be executed in unscheduled environment
- constructorArguments: Any - Arguments passed to _this in constructor (if a constructor exists)
- Return Value:
- HashMap
Examples
- Example 1:
- private _declaration = [ ["#flags", ["sealed"]], ["#create", { hint "Hello!" }], ["#clone", { hint "We were copied!" }], ["#delete", { hint "Goodbye" }], ["#str", { "My HashMap Object" }], ["Method", { hint "Method has been called" }] ]; private _hashMapObject = createHashMapObject _declaration; // hints "Hello!" _hashMapObject call ["Method"]; // hints "Method has been called" hint str _hashMapObject; // hints "My HashMap Object" private _shallowCopy = _hashMapObject; // no hint private _deepCopy = +_hashMapObject; // hints "We were copied!" // at the end of the scope, _hashMapObject is deleted and hints "Goodbye"
Additional Information
- See also:
- call createHashMap
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note