Re: Create an empty json object with std.json

2016-01-22 Thread Borislav Kosharov via Digitalmars-d-learn
On Friday, 22 January 2016 at 11:53:11 UTC, Andrea Fontana wrote: If you declare a JSONValue like this: JSONValue json; then: assert(json.type() == JSON_TYPE.NULL); Documentation at https://dlang.org/phobos/std_json.html#.JSONValue.type.2 suggests not to change type but to assign a new valu

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Borislav Kosharov via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 15:25:58 UTC, wobbles wrote: On Tuesday, 19 January 2016 at 14:07:50 UTC, Borislav Kosharov wrote: On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: [...] I want to use float time in a game where I call the update method passing the delta

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Borislav Kosharov via Digitalmars-d-learn
On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: In general, using floating point values with time is an incredibly bad idea. It can certainly make sense when printing stuff out, but using it in calculations is just asking for trouble given all of the unnecessary imprecision

Re: core.time Duration how to get units in double/float format?

2016-01-17 Thread Borislav Kosharov via Digitalmars-d-learn
On Sunday, 17 January 2016 at 18:57:13 UTC, biozic wrote: On Sunday, 17 January 2016 at 14:43:26 UTC, Borislav Kosharov wrote: Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using .total!"se

core.time Duration how to get units in double/float format?

2016-01-17 Thread Borislav Kosharov via Digitalmars-d-learn
Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using .total!"seconds" returns a long and if the duration is less than 1 second I get 0. My question is whats the right way to do it. Because I saw t

How to split a string/array with multiple separators?

2015-12-16 Thread Borislav Kosharov via Digitalmars-d-learn
I want to split a string using multiple separators. In std.array the split function has a version where it takes a range as a separator, but it works differently than what I want. Say if I call it with " -> " it will search for the whole thing together. I want to pass split a list of separators

Re: How to check if JSONValue of type object has a key?

2015-10-08 Thread Borislav Kosharov via Digitalmars-d-learn
Thanks guys that was I was looking for!

How to check if JSONValue of type object has a key?

2015-10-06 Thread Borislav Kosharov via Digitalmars-d-learn
I'm using std.json for parsing json. I need to check if a specific string key is in JSONValue.object. The first thing I tried was: JSONValue root = parseJSON(text); if(root["key"].isNull == false) { //do stuff with root["key"] } But that code doesn't work, because calling root["key"] will

Re: Is enum static?

2013-08-20 Thread Borislav Kosharov
On Tuesday, 20 August 2013 at 19:33:25 UTC, John Colvin wrote: On Tuesday, 20 August 2013 at 19:25:56 UTC, Jonathan M Davis wrote: On Tuesday, August 20, 2013 20:38:52 John Colvin wrote: On Tuesday, 20 August 2013 at 17:02:07 UTC, Jonathan M Davis wrote: > On Tuesday, August 20, 2013 12:54:29

What std functions are CTFE?

2013-08-19 Thread Borislav Kosharov
How do I know which functions are CTFE? I mean from the ones in std. I think there should be some icon or marker in the docs that indicates which function can be called during compilation. I remember that there was a compile time bool that checks if the current function is called during compil

Re: Is enum static?

2013-08-19 Thread Borislav Kosharov
So if I want to have a string constant it is a lot better to declare it as: static immutable string MY_STRING = "Some string"; Because it won't be duplicated?

Re: How to send a command to the system?

2013-08-09 Thread Borislav Kosharov
On Wednesday, 7 August 2013 at 22:06:16 UTC, Ali Çehreli wrote: On 08/07/2013 08:12 AM, Borislav Kosharov wrote: I want to send a pause command to the system like in C++: system("pause"); Or like in Ruby: `pause` Something like that. I searched the library, but I haven't fo

Re: Is enum static?

2013-08-08 Thread Borislav Kosharov
On Thursday, 8 August 2013 at 21:49:31 UTC, Ali Çehreli wrote: On 08/08/2013 02:45 PM, Borislav Kosharov wrote: If I have any enum in a class is it one for all instances or one per instance? Also are enums one per thread or only one? More than that. :) enums are manifest constants. Imagine

Is enum static?

2013-08-08 Thread Borislav Kosharov
If I have any enum in a class is it one for all instances or one per instance? Also are enums one per thread or only one?

Re: How to send a command to the system?

2013-08-07 Thread Borislav Kosharov
On Wednesday, 7 August 2013 at 15:21:43 UTC, Dicebot wrote: On Wednesday, 7 August 2013 at 15:12:09 UTC, Borislav Kosharov wrote: I want to send a pause command to the system like in C++: system("pause"); Or like in Ruby: `pause` Something like that. I searched the library, but

How to send a command to the system?

2013-08-07 Thread Borislav Kosharov
I want to send a pause command to the system like in C++: system("pause"); Or like in Ruby: `pause` Something like that. I searched the library, but I haven't found it. I tough that it might be std.system, but it was only to check the OS at runtime.