if เป็นนิพจน์ใน Kotlin — มันจะส่งกลับค่า นั่นหมายความว่าคุณสามารถกำหนด val result = if (cond) a else b ได้ สาขาจะต้องเป็นประเภทที่เข้ากันได้ เมื่อแทนที่สายโซ่ยาวของ if-else และยังเป็นนิพจน์อีกด้วย คุณสามารถจับคู่ค่าคงที่ ประเภท หรือใช้เงื่อนไขที่กำหนดเองกับตัวป้องกันบูลีนได้
ถ้าเป็นการแสดงออก
Full content is available with a subscription.
Get full access to all courses on the platform for one year with a single payment.
▼
Unlike other platforms that charge per course, here you get everything for one price, and after one year of use there will be no automatic charge for the following year.