Skip to content

Commit e9444ff

Browse files
committed
[Truffle] - Implements String#clear
1 parent 2090571 commit e9444ff

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,4 +1249,25 @@ public RubyString capitalize(RubyString string) {
12491249

12501250
}
12511251

1252+
1253+
@CoreMethod(names = "clear")
1254+
public abstract static class ClearNode extends CoreMethodNode {
1255+
1256+
public ClearNode(RubyContext context, SourceSection sourceSection) {
1257+
super(context, sourceSection);
1258+
}
1259+
1260+
public ClearNode(ClearNode prev) {
1261+
super(prev);
1262+
}
1263+
1264+
@Specialization
1265+
public RubyString clear(RubyString string) {
1266+
notDesignedForCompilation();
1267+
1268+
string.set(ByteList.create(""));
1269+
return string;
1270+
}
1271+
}
1272+
12521273
}

0 commit comments

Comments
 (0)