Comments (5)
Thanks a lot for the ping.
I added a quick fix from my phone: #262
I don't know how this passed and got through our CI systems, but I will investigate once I am back home in a few days.
from english.
You've added extra curly brackets in the switch statement, and it does compiles now.
The reason for this should be explained in description, because it is not obvious why these are mandatory.
from english.
I would propose this as example code:
import std.algorithm, std.conv, std.range,
std.stdio, std.traits;
struct Config
{
int runs, port;
string name;
}
void main()
{
Config conf;
// use the generated parser for each entry
"runs=1,port=2,name=hello"
.splitter(",")
.each!(e => conf.parse(e));
conf.writeln;
}
void parse(Conf)(ref Conf c, string entry)
{
auto r = entry.splitter("=");
auto key = r.front, value = r.dropOne.front;
Switch: switch (key)
{
static foreach (idx, field; Conf.tupleof)
{
case field.stringof:
c.tupleof[idx] =value.to!(typeof(field));
break Switch;
}
default:
assert (0, "Unknown member name.");
}
}
from english.
Good idea. I just wanted to fix it.
Would you mind opening a PR for your proposed improvement?
(it's really hard to do this from my phone and I am still backpacking for a few days)
from english.
works for me
from english.
Related Issues (20)
- Explain template parameters before it was used
- Convert the imports in all tour examples to selective imports
- Further Reading is missing HOT 3
- Configure your editor
- Raw string error
- Add D in action chapter HOT 3
- Language selection on top
- Is text description for Casear encryption wrong? HOT 2
- on basics/type-qualifiers - example's writeln output consistency - proposal HOT 2
- Add a page on pattern matching HOT 1
- on basics/ranges - possible wrong instance HOT 1
- on gems/functional-programming use of deprecated resources - replacement proposal HOT 2
- Doc examples doesn't run due to dependency error HOT 3
- `ld` throw error when `dub run dlang-tour -- --lang-dir .` HOT 3
- Proposal for a better opApply example
- Multidimensional Array declaration
- Page got grieffed on dlang.org HOT 3
- vibed/web-server.md code example build error. HOT 1
- Need much, much better instructions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from english.