「Swift入門」descriptionで数値を文字列に変換するサンプル

説明
数値.description
使用例

let cftA  = -2.345
let resultA  = cftA.description 
print("文字列A value: " + resultA.description)
 
let cftB  = 5678
let resultB  = cftB.description 
print("文字列B value: " + resultB.description)
 
let cftC  = 9.567
let resultC  = cftC.description 
print("文字列C value: " + resultC.description)

実行結果
$ swift test15.swift
文字列A value: -2.345
文字列B value: 5678
文字列C value: 9.567

Swift

Posted by arkgame