LoginSignup
26
17

More than 5 years have passed since last update.

Goでsliceに要素追加, slice同士の結合

Posted at

スライスは[]<型>で定義する. 要素の追加はappend

var tasks []string
append(tasks, "todo1")

スライス同士の結合(concat)もappendだが, 第二引数に...を付けるのが妙な感じ.

var tasks_without_due []string
append(tasks, tasks_without_due...)
26
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
17