Re: Unhandled exception: key not found [KeyError]

2017-11-05 Thread Udiknedormin
@Araq Nice riposte. By the way: I never noticed {} is a valid multi-argument operator, actually! It looks a little... unnimish. ^^"

Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread sky_khan
@Araq, English is not my native language. When I started programming as a child, my all English knowledge was consisting of "What is this? This is a pencil" So I learned programming by reading and tinkering other people's code and learned English by trying to understand programming manuals, all

Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread alfrednewman
Thank you guys ! @mratsim, off topic: [https://twitter.com/DeepMindAI/status/920696139657240576](https://twitter.com/DeepMindAI/status/920696139657240576) Cool !!

Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread Araq
[https://nim-lang.org/docs/json.html#dynamically-retrieving-fields-from-json](https://nim-lang.org/docs/json.html#dynamically-retrieving-fields-from-json) > To retrieve the value of "key" you can do the following: > > doAssert jsonNode["key"].getFNum() == 3.14 > > The [] operator will raise an e

Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread mratsim
Issue raised here: [https://github.com/nim-lang/Nim/issues/6531](https://github.com/nim-lang/Nim/issues/6531) Remember, with 4 PRs this month, you get a Hacktoberfest shirt

Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread jlp765
Ironically, it is newbies who recognize what is missing. Add a **PR** as you learn, so others can benefit. It also gets you familiar with contributing to Nim. There have been many suggestions of a **cookbook** for easy cut and paste of example code. It hasn't really gained traction, unfortunate

Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread alfrednewman
@sky_khan, I agree with you. The more examples the better! I am also learning Nim ... one of the main problems I had (and I have) is precisely the absence of examples in the documentation. In addition, I would kindly ask a favor for the older staff - please create more examples in the documenta

Re: Unhandled exception: key not found [KeyError]

2017-10-18 Thread sky_khan
hmm, couldnt see that coming. I partly blame documentation. I wish It was categorized by purpose. Not stacks of procs, templates, macros but constructors/initializers, destructors, getters, setters, (for json module) parsing etc. More examples would not be bad either.

Re: Unhandled exception: key not found [KeyError]

2017-10-18 Thread Araq
field1 = jz{"node1"}.getStr

Re: Unhandled exception: key not found [KeyError]

2017-10-18 Thread sky_khan
I'm learning Nim myself by trying to write this, seems working import json var field1, field2, field3 : string var jz : JsonNode = %* {"node1": "Node1Value","node3":nil} template nodeAsStr(n:JsonNode,key:string,default:string="*NoValue*"): string = if n!=n

Unhandled exception: key not found [KeyError]

2017-10-18 Thread alfrednewman
Hi, please consider the code below. import json var field1, field2, field3 : str var jz : JsonNode field1 = jz["node1"].getStr field2 = jz["node2"].getStr field3 = jz["node3"].getStr Sometimes the nodes node1, node2 and/or node3 are available at my