Int
Method Overview
| Name | Description | Return |
|---|
| toCurrencyString() | แปลง Integer ให้เป็น String ที่อยู่ในรูปแบบค่าเงิน | String |
| isInRange() | ตรวจสอบค่าของ Integer ว่าอยู่ในช่วงที่กำหนดหรือไม่ | Boolean |
| toString() | แปลง Integer ให้เป็น String โดยสามารถกำหนดค่า Default ที่จะ return ได้เมื่อค่า Integer เป็น null | String |
Method Details
func toCurrencyString(digit: Int = 0) -> String
แปลง Integer ให้เป็น String ที่อยู่ในรูปแบบค่าเงิน
Parameters
| Name | Description | Type |
|---|
| digit | จำนวนตำแหน่งทศนิยม | Int |
Returns
| Type | Description |
|---|
| String | Return String ของตัวเลข |
func isInRange(min: Int, max: Int) -> Bool
ตรวจสอบค่าของ Integer ว่าอยู่ในช่วงที่กำหนดหรือไม่
Parameters
| Name | Description | Type |
|---|
| min | จำนวนต่ำสุดของตัวเลขที่ต้องการ | Int |
| max | จำนวนสูงสุดของตัวเลขที่ต้องการ | Int |
Returns
| Type | Description |
|---|
| Boolean | Return true เมื่อค่าของ Integer อยู่ในช่วงที่กำหนด และ return false เมื่อค่าของ Integer ไม่อยู่ในช่วงที่กำหนด |
static func toString(_ int: Int?, defaultString: String = "-") -> String
แปลง Integer ให้เป็น String โดยสามารถกำหนดค่า Default ที่จะ return ได้เมื่อค่า Integer เป็น null
Parameters
| Name | Description | Type |
|---|
| int | Integer ที่ต้องการแปลง | Int |
| defaultString | String ที่ต้องการกำหนดให้เป็น Default เมื่อค่าของ Integer เป็น null | String |
Returns
| Type | Description |
|---|
| String | Return String ของตัวเลข |