-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If an argument is missing, it's value is "nil" (a string), not nil (the real nil). #22
Comments
Please clarify (give an example that fails). |
Consider the following simple example: import docopt
const doc = """
Foo.
Usage:
doco do [--param=<some-param>]
doco (-h | --help)
doco --version
Options:
-h --help Show this screen.
-v --version Show version.
-p --param=<some-param> Some param without default value.
"""
let args = docopt(doc, version = "0.1.0")
if args["do"]:
let param = $args["--param"] # expected to be nil if not passed
echo param.isNil
echo param == "nil" Compile and run it:
As you can see, if |
You are converting the value to string using |
Terribly sorry. What a stupid mistake... |
@BlaXpirit Still, it's a bit weird that $ applied to I'm asking for two reasons:
|
I am sure that applying Nim's shenanigans with imports and availability of methods is a whole another topic... |
I'm sorry, it seems like I am incorrect, and |
@BlaXpirit So, do you too think that $ applied to vkNone should return nil? IMHO it makes perfect sense. |
There's no contradiction with my proposal. |
Here's another example of what looks like a problem. The following script:
Compiles without errors on Nim 0.16.0 (Ubuntu 16.04, x86_64). When the compiled program is run with no arguments:
When run with an argument:
When run with the argument
So how do we test for You could sort this out by providing a |
I have an
isNil
check in my code that used to work with the older version. Now it breaks becauseisNil
is false due to the value being "nil," notnil
.The text was updated successfully, but these errors were encountered: