LoginSignup
0

More than 5 years have passed since last update.

文字列配列 []string から要素を指定して削除する

Posted at
// 文字列配列から指定したindexの要素を削除する
// 注意: runtime error: out of range 発生する恐れ有り
func unset(str []string, index int) []string {
    if index >= 0 {
        return append(str[:index], str[index+1:]...)
    } else {
        return append(str[:len(str)+index], str[len(str)+index+1:]...)
    }
}

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
0