いくつかの演算子[AppleScript]
リストの値比較で躓いてしまったので、少し整理。
AppleScriptを使ってみるよ!(言語編1/2) - seraphyの日記
が参考になりました。
等価演算子は
(* 等価演算子 *) log 1 = "1" -- false log "1" is 1 -- false log 1 is equal to 0 -- false log 1 is not 0 -- true log 1 is not equal to 0 -- true
というのがあるらしい。このあたりは、基本なので問題なし。
あと、
(* リストまたは文字列に対する演算 *) log "abcdefg" starts with "ab" -- true : "ab"で始まっているか? log "abcdefg" starts with "g" -- false
log "abcdefg" ends with "fg" -- true : "fg"で終わっているか? log "abcdefg" ends with "ab"
というのがあるようだ。
これは何かに使えそう。
さらに、
(* リスト、文字列、レコードに対する演算 *) log {3, 4, 5, 6} contains 4 -- true : 4を含むか? log {3, 4, 5, 6} contains {4, 5} -- true : 4, 5の並びがあるか?
というものもあるらしい。このcontainsを使うことで、当面の躓きが解消できた。
それについてはまた今度。