On Monday, 3 December 2012 at 23:42:38 UTC, bearophile wrote:
deed:
How is a playing card's rank represented most elegantly in
code?
Maybe with an enum?
enum Card { J, Q, ...}
If you have to store many of them then maybe giving them a size
of one byte is better:
enum Card : ubyte { Ace, Two, ..., Q, ...}
Bye,
bearophile
Using enum Rank { J=11, Q, K, A } doesn't enable the function
signature to be foo(Rank rank) when calling with 2, 3, .. 10,
right?
And using enum Rank { two, three, four, ... , K, A } is not
elegant.
I'd like to be able to call foo(Rank rank) with foo(3) and foo(Q).