Browse Source

Add Cards.String

master v0.1.3
Trevor Slocum 2 years ago
parent
commit
df7bd71a3b
  1. 16
      cards.go

16
cards.go

@ -1,6 +1,9 @@ @@ -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) { @@ -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