Commit 47c53583

47c53583cdbfMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Integer#clamp(range) and String#clamp(min,max | range)

Integer#clamp(a..b) clamps to the range bounds; String#clamp compares with strcmp, accepting (min, max) or a string range (a..z).

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
47c53583cdbf
Parent
990eca08cf9e

src/analyze.cmodifiedView file

@@ -372,7 +372,7 @@
372372 !strcmp(name, "capitalize") || !strcmp(name, "reverse") ||
373373 !strcmp(name, "strip") || !strcmp(name, "lstrip") ||
374374 !strcmp(name, "rstrip") || !strcmp(name, "chomp") ||
375- !strcmp(name, "chop") || !strcmp(name, "chr")) return TY_STRING;
375+ !strcmp(name, "chop") || !strcmp(name, "chr") || !strcmp(name, "clamp")) return TY_STRING;
376376 if (!strcmp(name, "[]") || !strcmp(name, "slice")) return TY_STRING;
377377 if (!strcmp(name, "index") || !strcmp(name, "to_i")) return TY_INT;
378378 if (!strcmp(name, "to_f")) return TY_FLOAT;