mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 06:23:25 +00:00
Swapping asArray parameter order
In reaction to https://github.com/nim-lang/Nim/pull/6640#issuecomment-341528413
This commit is contained in:
@@ -706,14 +706,14 @@ template newSeqWith*(len: int, init: untyped): untyped =
|
||||
|
||||
when not defined(nimscript):
|
||||
import macros
|
||||
macro asArray*(values: typed, targetType: typedesc): untyped =
|
||||
macro asArray*(targetType: typedesc, values: typed): untyped =
|
||||
## applies a type conversion to each of the elements in the specified
|
||||
## array literal. Each element is converted to the ``targetType`` type..
|
||||
##
|
||||
## Example:
|
||||
##
|
||||
## .. code-block::
|
||||
## let x = asArray([0.1, 1.2, 2.3, 3.4], int)
|
||||
## let x = asArray(int, [0.1, 1.2, 2.3, 3.4])
|
||||
## doAssert x is array[4, int]
|
||||
##
|
||||
## Short notation for:
|
||||
@@ -1018,7 +1018,7 @@ when isMainModule:
|
||||
doAssert seq2D == @[@[true, true], @[true, false], @[false, false], @[false, false]]
|
||||
|
||||
when not defined(nimscript): # asArray tests
|
||||
let x = asArray([1.2, 2.3, 3.4, 4.5], int)
|
||||
let x = asArray(int, [1.2, 2.3, 3.4, 4.5])
|
||||
doAssert x is array[4, int]
|
||||
|
||||
when not defined(testing):
|
||||
|
||||
Reference in New Issue
Block a user