Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

List manipulation methods

Method

subarraysIn:paddedWith:error:

Summary

Assumes the input is a list of lists, and the pad item will be used to pad out any sublists that are shorter than the longest

Signature

+ (NSArray *)subarraysIn:(NSArray *)listOrArray paddedWith:(id)pad error:(NSError *__autoreleasing *)outError

Parameters

listOrArray = a list or array

pad = the item to insert

outError = missing value or reference

Result

An array of arrays

Availability

Version 1.0.0

Notes

If you set outError to reference, the result will be a list of two items. If there is no error, the first item will be the result of the method and the second will be missing value. If there is an error, the first item will be missing value and the second item with be an NSError.

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set theLists to {{1.1, 2.1, 3, 4, 5}, {1, 2, 3}, {1, 2}}

set theResult to current application's SMSForder's subarraysIn:theLists paddedWith:0 |error|:(missing value)

ASify from theResult

--> {{1.1, 2.1, 3, 4, 5}, {1, 2, 3, 0, 0}, {1, 2, 0, 0, 0}}

theResult as list -- 10.11 only

--> {{1.1, 2.1, 3, 4, 5}, {1, 2, 3, 0, 0}, {1, 2, 0, 0, 0}}

theResult as list -- 10.9 and 10.10

--> {{1.100000023842, 2.099999904633, 3, 4, 5}, {1, 2, 3, "x", "x"}, {1, 2, "x", "x", "x"}}


set {theResult, theError} to current application's SMSForder's subarraysIn:theLists paddedWith:"x" |error|:(reference)

if theResult = missing value then error (theError's localizedDescription() as text)

ASify from theResult

--> {{1.1, 2.1, 3, 4, 5}, {1, 2, 3, "x", "x"}, {1, 2, "x", "x", "x"}}

theResult as list -- 10.11 only

--> {{1.1, 2.1, 3, 4, 5}, {1, 2, 3, "x", "x"}, {1, 2, "x", "x", "x"}}

theResult as list -- 10.9 and 10.10

--> {{1.100000023842, 2.099999904633, 3, 4, 5}, {1, 2, 3, "x", "x"}, {1, 2, "x", "x", "x"}}


Click here to open script in a script editor