parent
9bacdd64c1
commit
c34cb101b8
2 changed files with 15 additions and 7 deletions
|
|
@ -45,15 +45,24 @@ let a = case str1:
|
|||
echo "no good"
|
||||
quit("quiting")
|
||||
|
||||
let b = case str2:
|
||||
of nil, "": raise newException(ValueError, "Invalid boolean")
|
||||
elif str2[0] == 'Y': true
|
||||
elif str2[0] == 'N': false
|
||||
else: "error".quit(2)
|
||||
proc toBool(s: string): bool =
|
||||
case s:
|
||||
of nil, "": raise newException(ValueError, "Invalid boolean")
|
||||
elif s[0] == 'Y': true
|
||||
elif s[0] == 'N': false
|
||||
else: "error".quit(2)
|
||||
|
||||
|
||||
let b = "NN".toBool()
|
||||
|
||||
doAssert(a == true)
|
||||
doAssert(b == false)
|
||||
|
||||
static:
|
||||
#bug #7407
|
||||
let bstatic = "N".toBool()
|
||||
doAssert(bstatic == false)
|
||||
|
||||
var bb: bool
|
||||
doassert(not compiles(
|
||||
bb = case str2:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue