मेरे मामले में मैं एक आदिम बदलना चाहते हैं - बूलियनक्या कोई एक्सटेंशन फ़ंक्शन लिखने का कोई तरीका है जो ऑब्जेक्ट के मान को बदलता है?
मैं कोड की निम्न प्रकार पसंद आया कभी नहीं:
private var firstTime: Boolean = true
...
if (firstTime) {
// do something for the first time here
firstTime = false
}
अच्छा होगा अगर मैं जैसा कोई एक्सटेंशन समारोह हो सकता है:
if (firstTime.checkAndUnset()) {
// do something for the first time here
}
क्या यह संभव है?
के रूप में सरल उपयोग यह एक प्रयोग मामले में जहां एक [आलसी प्रतिनिधि] (https://kotlinlang.org/docs/reference/delegated-properties.html#lazy) में मदद मिलेगी है? –