Skip to content


[Truffle] - Implements String#clear
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Dec 22, 2014
1 parent 2090571 commit e9444ff
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/core/
Original file line number Diff line number Diff line change
Expand Up @@ -1249,4 +1249,25 @@ public RubyString capitalize(RubyString string) {


@CoreMethod(names = "clear")
public abstract static class ClearNode extends CoreMethodNode {

public ClearNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);

public ClearNode(ClearNode prev) {

public RubyString clear(RubyString string) {

return string;


1 comment on commit e9444ff

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this loses the encoding of the string. We need to improve this across the board, but figured I'd mention it here:

$ JRUBY_OPTS="-X+T" bin/jruby -e 's = "abc".force_encoding("UTF-8"); p; s.clear; p'

The encoding of the cleared string should remain UTF-8.

Please sign in to comment.