Created
March 9, 2021 04:31
-
-
Save cfultz/1ff38dc354cc6ccb6452bb8c5876f63a to your computer and use it in GitHub Desktop.
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
package dev.fultz.counter | |
fun main(){ | |
//immutable variable | |
//TODO: Add new functions | |
// val myString: String = "Android Masterclass" | |
// val myFloat: Float = 13.37F | |
// val myDouble: Double = 471.4288 | |
// val myByte: Byte = 25 | |
// val myInt: Int = 2020 | |
// val myLong: Long = 18881234567 | |
// val myBoolean: Boolean = true | |
// val myChar = "a" | |
// | |
// println("$myString, $myFloat, $myDouble, $myByte, $myInt, $myLong, $myBoolean, $myChar") | |
// | |
// var result = 5+3 | |
// val a = 5.0 | |
// val b = 3 | |
// var resultDouble : Double | |
// resultDouble = (a / b).toDouble() | |
// println("$resultDouble") | |
// | |
// val isEqual = 5==5 | |
// println("isEqual is $isEqual") | |
// | |
// val isNotEqual = 5!=5 | |
// println("isNotEqual is $isNotEqual") | |
// | |
// println("is5Greater3 ${5>3}") | |
// println("is5LowerEqual3 ${5<= 3}") | |
// | |
// var myNum = 5 | |
// myNum += 3 | |
// myNum *= 4 | |
// myNum++ | |
// println("myNum is $myNum") | |
// println("myNum is ${myNum++}") | |
// println("myNum is ${++myNum}") | |
// println("myNum is ${--myNum}") | |
// var heightPerson1 = 170 | |
// var heightPerson2 = 150 | |
// | |
// if (heightPerson1 > heightPerson2){ | |
// println("use raw force") | |
// } | |
// else if (heightPerson1 == heightPerson2){ | |
// println("fair match") | |
// } | |
// else { | |
// println("use technique") | |
// } | |
// val setAge = 31 | |
// | |
// if(setAge >= 30) | |
// println("You're old") | |
// | |
// if (setAge >= 21){ | |
// println("You may buy alcohol") | |
// } else if (setAge >= 18){ | |
// println("You may vote") | |
// } else if (setAge >= 16){ | |
// println("You may drive") | |
// } else { | |
// println("You are too young") | |
// } | |
// | |
// var name = "Caleb" | |
// if(name == "Caleb") { | |
// println("Welcome home $name!") | |
// }else{ | |
// println("Get out of here $name!") | |
// } | |
// var isRainy = true | |
// if(isRainy) | |
// println("It's Rainy") | |
// var season = 1 | |
// when(season){ | |
// 1 -> println("It's Spring!") | |
// 2 -> println("It's Summer!") | |
// 3 -> { | |
// println("It's Fall!") | |
// println("It's Autumn!") | |
// } | |
// 4 -> println("It's Winter!") | |
// else -> println("Invalid Season") | |
// } | |
// | |
// var month = 2 | |
// when(month){ | |
// in 3..5 -> println("Spring") | |
// in 6..8 -> println("Summer") | |
// in 9..11 -> println("Fall") | |
// 12, 1, 2 -> println("Winter") | |
// else -> println("Invalid") | |
// } | |
val age = 25 | |
when(age){ | |
!in 0..20 -> println("You may drink") | |
in 18..20 ->println("You may vote") | |
16,17 -> println("You may drive") | |
else -> println("You are too young") | |
} | |
var x : Any = 542 | |
when(x){ | |
is Int -> println("$x is an Int") | |
is Double -> println("$x is a Double") | |
is String -> println("$x is a String") | |
else -> println("$x is none of the above") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment