Functions • Lesson 39/100+50 XP

Extension Functions

Add functions to existing types

📚
Learn
💻
Code
Quiz
🏆
Practice
Complete

📚 Lý thuyết

**Extension Functions** thêm method mới cho class có sẵn mà không cần kế thừa. **Cú pháp:** ```kotlin fun Type.functionName(): ReturnType ``` **Đặc điểm:** - this refer đến receiver object - Không thực sự modify class - Rất hữu ích cho utility functions