Browse Source

Add Cards.String

master v0.1.3
Trevor Slocum 1 year ago
parent
commit
df7bd71a3b
1 changed files with 15 additions and 1 deletions
  1. +15
    -1
      cards.go

+ 15
- 1
cards.go View File

@ -1,6 +1,9 @@
package joker
import "sort"
import (
"sort"
"strings"
)
// Cards is a slice of Cards.
type Cards []Card
@ -73,6 +76,17 @@ func (c Cards) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
}
func (c Cards) String() string {
var s strings.Builder
for i := range c {
if i > 0 {
s.WriteRune(',')
}
s.WriteString(c[i].String())
}
return s.String()
}
// Copy returns a copy of the supplied cards.
func (c Cards) Copy() Cards {
cc := make(Cards, len(c))


Loading…
Cancel
Save