requireConsistent2DArray
The strict counterpart of require2DArray: the value must be a non-empty array of arrays and every row must be as wide as the first.
When the rows differ, the default message reports the offending row and both widths — the information needed to fix the call, and precisely what Range#setValues withholds when it rejects a ragged matrix. A custom message replaces the default in both failure cases.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The value to validate. |
|
| The exception message. A default describing the mismatch is used when omitted. |
Returns
T[][] — the same value, typed as a two-dimensional array.
Throws
Exception | Condition |
|---|---|
| The value is not a non-empty array of arrays. |
| The rows do not all have the same length. |
Examples
A matrix that is safe to write
The message names the offending row
See also
isConsistent2DArray— the same test as a predicate.nonConsistent2DArray— the negated predicate.require2DArray— accepts ragged rows.
Source
This documentation was generated with AI (Claude) from the library's source code.