Commit 2279bb96

2279bb96a84bMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified

Description

Add String#[] (character indexing), fix duplicate sp_str_char_at

s[0] → first char, s[-1] → last char, out of bounds → "". Dispatched before array/proc [] handler in codegen_expr.

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

Details

Commit
2279bb96a84b
Parent
d5706015539c

examples/bm_strindex.rbaddedView file

1+s = "hello world"
2+puts s[0] # h
3+puts s[6] # w
4+puts s[-1] # d
5+puts s[4] # o
6+puts "done"