On Saturday, 5 August 2017 at 20:11:27 UTC, Matthew Remmel wrote:
On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel
wrote:
I feel like I'm missing something, but there has to be an
easier way to convert a value into an enum tha
On Saturday, 5 August 2017 at 20:11:27 UTC, Matthew Remmel wrote:
On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel
I'm annoyed that I didn't think of trying to cast it. That
works great if the value exists in the enum. It do
On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel
wrote:
I feel like I'm missing something, but there has to be an
easier way to convert a value into an enum than switching over
every possible value: i.e
[...]
Capitals c =
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:
I feel like I'm missing something, but there has to be an
easier way to convert a value into an enum than switching over
every possible value: i.e
[...]
Capitals c = cast(Capitals)"Chicago";
writeln(c);// Illinois
On 08/05/2017 07:05 PM, ag0aep6g wrote:
E enumFromValue(E)(string s)
The type of `s` should probably be a template parameter as well.
On 08/05/2017 05:33 PM, Matthew Remmel wrote:
I feel like I'm missing something, but there has to be an easier way to
convert a value into an enum than switching over every possible value: i.e
enum Capitals {
Indiana = "Indianapolis",
Illinois = "Chicago",
Ohio = "Columbus"
}
Ca
On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel
wrote:
Any ideas?
You can use to! in std.conv:
import std.stdio;
import std.conv;
enum Foo
{
A = "A",
B = "B"
}
void main()
{
writeln("A".to
On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel
wrote:
Any ideas?
You can use to! in std.conv:
import std.stdio;
import std.conv;
enum Foo
{
A = "A",
B = "B"
}
void main()
{
writeln("A".to
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:
Any ideas?
You can use to! in std.conv:
import std.stdio;
import std.conv;
enum Foo
{
A = "A",
B = "B"
}
void main()
{
writeln("A".to!Foo);
}
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:
I feel like I'm missing something, but there has to be an
easier way to convert a value into an enum than switching over
every possible value: i.e
[...]
What you want is already in the standard library.
std.conv.to can convert
I feel like I'm missing something, but there has to be an easier
way to convert a value into an enum than switching over every
possible value: i.e
enum Capitals {
Indiana = "Indianapolis",
Illinois = "Chicago",
Ohio = "Columbus"
}
Capitals enumFromValue(string s) {
switch (s) {
11 matches
Mail list logo