This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| smutbook:classes:util:array_prototypes [2023/08/06 20:22] – created lee | smutbook:classes:util:array_prototypes [2026/08/25 13:58] (current) – removed lee | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Array Prototypes ====== | ||
| - | |||
| - | ===== Array.prototype.commaList() ===== | ||
| - | |||
| - | Assuming that it is an array of strings, returns a proper serial-comma-separated description of the list including " | ||
| - | |||
| - | < | ||
| - | // Returns "a two-dollar pistol, a Stetson hat, and a shotgun": | ||
| - | [ "a two-dollar pistol", | ||
| - | |||
| - | // Returns "a two-dollar pistol and a Stetson hat": | ||
| - | [ "a two-dollar pistol", | ||
| - | |||
| - | // Returns "a two-dollar pistol": | ||
| - | [ "a two-dollar pistol" | ||
| - | |||
| - | // Returns " | ||
| - | [].commaList() | ||
| - | </ | ||
| - | |||
| - | ===== Array.prototype.aList ===== | ||
| - | |||
| - | Assuming an array of [[PersistentObject]]s (or subclasses thereof), returns a serial-comma-separated description like .commaList(), | ||
| - | < | ||
| - | // Assuming pistol, hat, and shotgun are all valid PersistentObjects, | ||
| - | // returns "a two-dollar pistol, a Stetson hat, and a shotgun": | ||
| - | [ pistol, hat, shotgun ].aList() | ||
| - | </ | ||
| - | |||
| - | ===== Array.prototype.theList ===== | ||
| - | |||
| - | Assuming an array of [[PersistentObject]]s (or subclasses thereof), returns a serial-comma-separated description like .commaList(), | ||
| - | < | ||
| - | // Assuming pistol, hat, and shotgun are all valid PersistentObjects, | ||
| - | // returns "the two-dollar pistol, the Stetson hat, and the shotgun": | ||
| - | [ pistol, hat, shotgun ].theList() | ||
| - | </ | ||
| - | |||