Commit 66496dfb

66496dfba04cMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified

Description

feat: add String#lines

Returns an array of lines by splitting on newlines. Note: unlike Ruby, trailing newlines are not preserved in each element (uses sp_str_split with "\n").

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

Details

Commit
66496dfba04c
Parent
d8f48ecedb42

spinel_codegen.rbmodifiedView file

@@ -1635,6 +1635,9 @@
16351635 if mname == "split"
16361636 return "str_array"
16371637 end
1638+ if mname == "lines"
1639+ return "str_array"
1640+ end
16381641 if mname == "gsub"
16391642 return "string"
16401643 end
@@ -11637,6 +11640,10 @@
1163711640 end
1163811641 return "sp_str_split(" + rc + ", " + compile_arg0(nid) + ")"
1163911642 end
11643+ if mname == "lines"
11644+ @needs_str_array = 1
11645+ return "sp_str_split(" + rc + ", \"\\n\")"
11646+ end
1164011647 if mname == "match?"
1164111648 re_args_id = @nd_arguments[nid]
1164211649 if re_args_id >= 0