Echo Hollow

Because Pr0n is the Highest Form of Art.

User Tools

Site Tools


smutbook:classes:util:array_prototypes

Array Prototypes

Array.prototype.commaList()

Assuming that it is an array of strings, returns a proper serial-comma-separated description of the list including “and”, or “nothing” if the list is empty.

// Returns "a two-dollar pistol, a Stetson hat, and a shotgun":
[ "a two-dollar pistol", "a Stetson hat", "a shotgun" ].commaList() 

// Returns "a two-dollar pistol and a Stetson hat":
[ "a two-dollar pistol", "a Stetson hat" ].commaList()

// Returns "a two-dollar pistol":
[ "a two-dollar pistol" ].commaList()

// Returns "nothing":
[].commaList()

Array.prototype.aList

Assuming an array of PersistentObjects (or subclasses thereof), returns a serial-comma-separated description like .commaList(), but using those objects' .aName fields.

// 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 PersistentObjects (or subclasses thereof), returns a serial-comma-separated description like .commaList(), but using those objects' .theName fields.

// Assuming pistol, hat, and shotgun are all valid PersistentObjects,
//  returns "the two-dollar pistol, the Stetson hat, and the shotgun":
[ pistol, hat, shotgun ].theList() 

smutbook/classes/util/array_prototypes.txt · Last modified: 2023/08/06 20:23 by lee