「Groovy」範囲に指定値の存在を確認する

2021年8月31日

書式
boolean contains(Object obj)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class Arkxample {
static void main(String[] args) {
// def 整数の範囲
def cft = 2..12;
println(cft.contains(7));
println(cft.contains(13));
}
}
class Arkxample { static void main(String[] args) { // def 整数の範囲 def cft = 2..12; println(cft.contains(7)); println(cft.contains(13)); } }
class Arkxample { 
   static void main(String[] args) { 
      // def 整数の範囲
      def cft = 2..12; 
            
      println(cft.contains(7)); 
      println(cft.contains(13)); 
   } 
}

結果
true
false

Groovy

Posted by arkgame