Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


smutbook:classes:util:arrayprototypes

This is an old revision of the document!


Array Prototypes

Array.prototype.commaList()

Returns a proper serial-comma-separated string list of the list elements' toString() values, 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.CommaList()

As above, but with the first letter of the returned string capitalized.

Array.prototype.aList

Assuming an array of PersistentObjects (or subclasses thereof) or persistent object IDs (may be mixed), returns a serial-comma-separated description like .commaList(), but using those objects' .aName methods.

// Assuming pistol and shotgun are valid PersistentObjects, and "hat" is the id of a valid 
//  PersistentObject, returns "a two-dollar pistol, a Stetson hat, and a shotgun":
[ pistol, "hat", shotgun ].aList() 

Array.prototype.AList()

As above, but with the first letter of the returned string capitalized.

Array.prototype.theList

Assuming an array of PersistentObjects (or subclasses thereof) or persistent object IDs (may be mixed), returns a serial-comma-separated description like .commaList(), but using those objects' .theName methods.

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

Array.prototype.TheList()

As above, but with the first letter of the returned string capitalized.

Array.prototype.nList

Assuming an array of PersistentObjects (or subclasses thereof), or persistent object IDs, or functions (may be mixed), returns a serial-comma-separated description like .commaList(), but using those objects' .name fields. Useful for things like “your such-and-suches”.

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

Array.prototype.NList()

As above, but with the first letter of the returned string capitalized.

smutbook/classes/util/arrayprototypes.1787691541.txt.gz · Last modified: by lee