Skip to content

Instantly share code, notes, and snippets.

// g100pon #6 範囲(Range)操作(基礎編:CRUD系操作とイテレーション)
// inclusive range
def inclusiveRange = 1..100
print "Is inclusiveRange[0] value 1:"
println inclusiveRange[0] == 1
print "Is inclusiveRange[99] value 100:"
println inclusiveRange[99] == 100
print "Is inclusiveRange contain 1:"
println inclusiveRange.contains(1)
print "Is inclusiveRange contain 100:"
// g100pon #4 マップ操作(基礎編:CRUD系操作とイテレーション)
def map = [atami:"onsen", hokkaido:"ski", price:100]
// atamiを読む
println map.get("atami")
// hokkaidoを更新
map["hokkaido"] = "kani"
println map.get("hokkaido")
// hokkaidoを削除
map.remove("hokkaido")
println map.containsKey("hokkaido")
// g100pon #2 リスト操作(基礎編:CRUD系操作とイテレーション)
def list = [1, "one", 2]
// 1番目をread
println list[0]
// 2番目をupdate
list[1] = "update"
println list[1]
// 3番目を削除
println "before removed size is " + list.size
list.remove(2)