isOlderVersion

fun isOlderVersion(current: String, latest: String): Boolean

Compares two semantic version strings and determines if the current version is older than the latest version.

This function splits the version strings by dots, parses each segment as an integer (defaulting to 0 if parsing fails), and compares corresponding segments from left to right. Missing segments are treated as zeros.

Example comparisons:

  • isOlderVersion("1.2.3", "1.2.4") -> true

  • isOlderVersion("1.3.0", "1.2.9") -> false

  • isOlderVersion("1.2", "1.2.0.1") -> true

Return

true if the current version is older than the latest version, false otherwise

Parameters

current

The current version string (e.g., "1.2.3")

latest

The latest version string (e.g., "1.2.4")