Created
July 2, 2019 13:11
-
-
Save rail-rate/f9086b06c6d785382bf8099157707d96 to your computer and use it in GitHub Desktop.
Range2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val five = 5 //まず値をセットする。 | |
val a : IntRange = 0..6 //ここで範囲を決める | |
val a1 = five in a //ここでBoolean型で範囲に入ってるかチェック | |
println("${five}は0から6の範囲に入っている? " + a1) //結果をtrueかfalseで確認 | |
val b : CharRange = 'A'..'E' | |
val c : CharRange = 'あ'..'お' | |
val b1 = 'C' in b //先に変数で値をセットしなくても直接調べることも出来る | |
val c1 = 'か' in c //先に変数で値をセットしなくても直接調べることも出来る | |
println("CはAからEの範囲に入ってる? " + b1) | |
println("かはあからおの範囲に入ってる? " + c1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment