Extensions can add new subscripts to an existing type. This example adds an integer subscript to Swift’s built-in Int type. This subscript [n] returns the decimal digit n places in from the right of the number
นามสกุลสามารถเพิ่มตัวห้อยใหม่เป็นชนิดที่มีอยู่ ตัวอย่างนี้เพิ่มตัวห้อยเป็นเลขจำนวนเต็มชนิด Int มี Swift ตัวห้อยนี้ [n] ส่งกลับตัวเลขทศนิยม n ตำแหน่งในจากด้านขวาของหมายเลข
ส่วนต่อขยายที่สามารถเพิ่มห้อยใหม่ในการพิมพ์ที่มีอยู่ ตัวอย่างนี้เพิ่มห้อยจำนวนเต็มสวิฟท์ในตัวชนิด Int นี้ห้อย [n] จะแสดงสถานที่ n ทศนิยมหลักมาจากด้านขวาของหมายเลข