Skip to content
Permalink
Browse files

Merge pull request #801 from sideshowcoder/add_string_chr

Add String#chr
  • Loading branch information
alex committed Jul 13, 2013
2 parents 298d07d + dcab0fd commit c3f8bb302cb5a29549bcc82763642e5637e46aae
Showing with 4 additions and 5 deletions.
  1. +4 −0 lib-topaz/string.rb
  2. +0 −5 spec/tags/core/string/chr_tags.txt
@@ -159,6 +159,10 @@ def strip
duplicate
end

def chr
self.dup[0] || self.dup
end

def replace(other)
raise RuntimeError.new("can't modify frozen #{self.class}") if frozen?
other = Topaz.convert_type(other, String, :to_str)
@@ -1,8 +1,3 @@
fails:String#chr returns a copy of self
fails:String#chr returns a String
fails:String#chr returns an empty String if self is an empty String
fails:String#chr returns a 1-character String
fails:String#chr returns the character at the start of the String
fails:String#chr returns a String in the same encoding as self
fails:String#chr understands multi-byte characters
fails:String#chr understands Strings that contain a mixture of character widths

0 comments on commit c3f8bb3

Please sign in to comment.
You can’t perform that action at this time.