Commit cbd79481 authored by Benjamin Summerton's avatar Benjamin Summerton

returns an empty seq instead of nil now

parent f3b86df4
......@@ -281,11 +281,11 @@ proc lap*(sw: var Stopwatch; num: int; incCur: bool = false): int64 =
## echo lapsSecs
## # --> @[1.000117, 0.500115, 0.200212]
##
## If lapping is turned off this will return `nil`.
## If lapping is turned off this will return an empty sequence
proc laps*(sw: var Stopwatch; incCur: bool = false): seq[int64] =
# Check for lapping=off
if not sw.isRecordingLaps:
return nil
return @[]
# Nope, we've got laps
var
......
......@@ -74,7 +74,7 @@ echo "lapCount=", sw.numLaps
echo "----"
echo "lapCount=", sw2.numLaps
var lapsSecs = if sw.isRecordingLaps: sw2.laps().map(proc(x: int64): float = secs(x)) else: nil
var lapsSecs = sw2.laps().map(proc(x: int64): float = secs(x))
echo "all laps(s)=", lapsSecs
echo ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment