Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
String s;
int x = a % 100;
if (x > 9 && x < 14) s = "th";
else s = switch (a % 10) {
case 1 -> "st";
case 2 -> "nd";
case 3 -> "rd";
default -> "th";
};
s = a + s;
if ((a mod 100) in [10..20]) then
s := 'th'
else
case (a mod 10) of
1: s := 'st';
2: s := 'nd';
3: s := 'rd';
otherwise
s := 'th';
end;
s := a.ToString + s;
array = 'st', 'nd', 'rd', 'th'
if 10 <= a % 100 <= 13:
suffix = array[-1]
else:
match value := a % 10:
case 1 | 2 | 3:
suffix = array[value - 1]
case _:
suffix = array[-1]
s = str(a) + suffix
s = if (a % 100).between?(9, 14) then
'th'
else
case a % 10
when 1 ; 'st'
when 2 ; 'nd'
when 3 ; 'rd'
else 'th'
end
end
s = a.to_s + s