Most elegant representation of a card's rank

deed none at none.none
Mon Dec 3 15:32:30 PST 2012


How is a playing card's rank represented most elegantly in code?

* Should be a customized uint/an own type representing uints in 
the range of 2 through 14.
* void foo(Rank rank) {  } // Accepts only the valid range
   foo(0);  // Error
   foo(2);  // Ok
   foo(10); // Ok

   alias J 11;
   alias Q 12;
   etc.,

   foo(J);  // Ok
   foo(Q);  // Ok
   foo(B);  // Error




More information about the Digitalmars-d-learn mailing list