fun divide(divisor:BigDecimal, scale: Int =
0,roundingMode: RoundingMode = RoundingMode.UNNECESSARY):Unit{
}
fun testDefaultParmas(){
divide(BigDecimal(
12.34))
divide(BigDecimal(
12.34),
8)
divide(BigDecimal(
12.34),
8,RoundingMode.HALF_DOWN)
divide(BigDecimal(
12.34),roundingMode = RoundingMode.HALF_DOWN)
}
class Student(
val name:String ,
val registered:Boolean, credits:Int){
constructor(name:String):this(name,
false,
0)
constructor(name:String, registered: Boolean):this(name,
false,
0)
}
class Student2(
val name: String,
val registered: Boolean =
false, credits: Int=
0){
}
abstract class DroppableList<E> : ArrayList<E>(){
fun drop(k: Int): List<E>{
val resultSize = size - k
when{
resultSize <=
0 ->
return emptyList<E>()
else -> {
val list = ArrayList<E>(resultSize)
for(index
in k..size-
1){
list.add(this[index])
}
return list
}
}
}
}
fun <E> drop(k: Int, list: List<E>): List<E>{
val resultSize = list.size -k
when{
resultSize <=
0 ->
return emptyList()
else ->{
val newList = ArrayList<E>(resultSize)
for(index
in k .. list.size-
1){
newList.add(list[index])
}
return newList
}
}
}
fun<E> List<E>.drop(k: Int):List<E>{
val resultSize = size -k
when{
resultSize <=
0 ->
return emptyList()
else ->{
val newList = ArrayList<E>(resultSize)
for(index
in k .. size-
1){
newList.add(this[index])
}
return newList
}
}
}
fun testExtendFun(){
val list = listOf(
1,
2,
3)
val dropedList = list.drop(
2)
}
fun Any?.safeEquals(other: Any?): Boolean{
if(this ==
null && other ==
null)
return true
if(this ==
null)
return false
return this.equals(other)
}
class Mappings{
private val map = hashMapOf<Int,String>()
private fun String.stringAdd():Unit{
map.put(hashCode(),this)
map.put(this@Mappings.hashCode(),this)
}
fun add(str: String): Unit = str.stringAdd()
}