function returns false, the value is definitely not null:
                  
                  
                      if (!x.isNullOrEmpty()) {
                  
                  
                          println(x.size) // Yay, smart cast to not-null!
                  
                  
                      }
                  
                  
                  }
                  
                  
                  
                  
                  
                  fun test(x: Any?) {
                  
                  
                      // If the function returns (does not throw), then the argument is true:
                  
                  
                      require(x is String) 
                  
                  
                      println(x.length) // Smart cast here too!
                  
                  
                  }
                  
                  
                
Это как раз надуманная дичь из всех статей про контракты, я прошу что-то реального, где без контрактов беда была.
Обсуждают сегодня