🖥

Go 言語で スライスを合体させてトランプの組み合わせを作る ( #go join multiple string slice n time

2020/03/16に公開
// https://golang.org/pkg/math/rand/

package main

import (
	"fmt"
)

func main() {
	cards := []string{"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"}
	cards4 := []string{}

	for i := 0; i < 4; i++ {
		cards4 = append(cards4, cards...)
	}

	fmt.Println(len(cards4)) // 52
	fmt.Println(cards4)      // [2 3 4 5 6 7 8 9 10 J Q K A 2 3 4 5 6 7 8 9 10 J Q K A 2 3 4 5 6 7 8 9 10 J Q K A 2 3 4 5 6 7 8 9 10 J Q K A]
}

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/3025

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2020-03-16

Discussion