Kotlin 與 Swift 語法對照:跨平台開發者 (2025年)

Kotlin 與 Swift 語法對照表(2025 年版) 在行動應用開發中, Kotlin 與 Swift 分別是 Android 與 iOS 的主流語言。雖然語法有些差異,但其實它們有很多相似之處。本文整理了常用的語法對照表,方便跨平台開發者快速上手。 1. 變數宣告 // Kotlin val name: String = "Alice" // 常數 var age: Int = 25 // 可變數 // Swift let name: String = "Alice" // 常數 var age: Int = 25 // 可變數 2. 條件判斷 // Kotlin if (age >= 18) { println("Adult") } else { println("Minor") } // Swift if age >= 18 { print("Adult") } else { print("Minor") } 3. 函式定義 // Kotlin fun greet(name: String): String { return "Hello, $name!" } // Swift func greet(_ name: String) -> String { return "Hello, \(name)!" } 4. 陣列與迴圈 // Kotlin val fruits = listOf("Apple", "Banana", "Cherry") for (fruit in fruits) { println(fruit) } // Swift let fruits = ["Apple", "Banana", "Cherry"] for fruit in fruits { print(f...

[Linux] About LSB: Linux Standard Base(Linux標準規範)

Linux is an Open Source Operating System(作業系統)
所以任何人都可以自由使用底層原始碼
修改成符合自身需求的版本並發布
負責維護的Linux基金會建立了一套規範

稱作 Linux標準規範(LSB, Linux Standard Base)

目標是定義各家散布版本(Distribution)之間的共通性

This mark assures developers and end-users that any "LSB Certified" application will work correctly on every "LSB Certified" distribution (來源)

對此,我們也可以透過此規範定義的指令
觀察到當前OS的Linux種類與版本:
 $ lsb_release -a 
有些OS安裝時就已經包含此套件(如 ubuntu ),有些則要另外安裝
像是 CentOS,我剛安裝 CentOS7 時輸入,會出現 command not found
此時,可以輸入
 $ yum provides lsb_release

會發現其包含在 redhat-lsb-core 
於是,只要安裝該套件後,應該就能使用了
$ sudo yum install redhat-lsb-core
安裝完成後,輸入
$ lsb_release -a 
畫面如下:

而Ubuntu 14.04LTS 畫面如下:

參考資料:
Linux標準規範 - 維基百科
Linux基金會 - 維基百科
Certification - The Linux Foundation
Linux lsb_release 指令,版本、種類的查詢(Linux Standard Base) | 香港矽谷
How to fix lsb_release command not found on CentOS 7.3 |Tutoral and Full Version Software

留言

這個網誌中的熱門文章

【Ubuntu】Terminal 複製貼上的方法 Copy & Paste

【Ubuntu】關閉預設畫面自動鎖定

[Java] HashMap資料結構簡介與用法