git преди 2 седмици
родител
ревизия
b5daf02eb3
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      src/main/kotlin/cn/qqck/kotlin/tools/String.kt

+ 5 - 0
src/main/kotlin/cn/qqck/kotlin/tools/String.kt

@@ -1,6 +1,11 @@
 package cn.qqck.kotlin.tools
 
 fun String.bytes() = this.toByteArray()
+fun String.bool(): Boolean? {
+    if (this == "1" || this == "t" || this == "T" || this == "true" || this == "True" || this == "yes" || this == "Yes") return true
+    if (this == "0" || this == "f" || this == "F" || this == "false" || this == "False" || this == "no" || this == "No") return false
+    return null
+}
 
 /**
  * 从当前字符串中获取指定子字符串前的内容。