Skip to main content

初期化.まとめて

Python

py
items = ['carrot', 'onion', 'potato']

Swift

swift
let items = ["carrot", "onion", "potato"]

Bash

bash
items=( "AA A" "bb" "cc" )
  • スペース区切りされるので、値に空白入る場合はクオート必須

Ruby

rb
items = ['carrot', 'onion', 'potato']

PowerShell

powershell
$items = @('carrot', 'onion', 'potato')

こうでも良さそうだが、可読性が良くない気がして

powershell
$items = 'carrot', 'onion', 'potato'

あと、@() の場合の区切り文字は ; でも良さそう