Returns a copy of _str_ with all characters in the intersection of
its arguments deleted. Uses the same rules for building the set of
characters as +String#count+.
What it means is that it builds a character set performing the
intersection of all arguments to the method. So if you do
s.delete("h", "he") the intersection of the arguments is "h", because
it's the only one present in all arguments. If the arguments don't
intersect nothing is deleted:
"Any other_str that starts with a caret (^) is negated. The sequence
c1—c2 means all characters between c1 and c2. "
This means that s.delete("^aeiou") will remove all consonants and
leave the vocals, and that s.delete("a-m") will delete all characters
between "a" and "m":
On Tue, Nov 24, 2009 at 2:41 PM, Ruby Newbee <rubynewbee@gmail.com> wrote:
Returns a copy of \_str\_ with all characters in the intersection of
its arguments deleted\. Uses the same rules for building the set of
characters as \+String\#count\+\.
"hello"\.delete "l","lo" \#=> "heo"
"hello"\.delete "lo" \#=> "he"
"hello"\.delete "aeiou", "^e" \#=> "hell"
"hello"\.delete "ej\-m" \#=> "ho"
What does this mean?
I can't understand for the rules.
ah~ thanks, I got it.
never saw this syntax in my other languages of programming,
···
2009/11/24 Jesús Gabriel y Galán <jgabrielygalan@gmail.com>:
On Tue, Nov 24, 2009 at 2:41 PM, Ruby Newbee <rubynewbee@gmail.com> wrote:
Returns a copy of \_str\_ with all characters in the intersection of
its arguments deleted\. Uses the same rules for building the set of
characters as \+String\#count\+\.
"hello"\.delete "l","lo" \#=> "heo"
"hello"\.delete "lo" \#=> "he"
"hello"\.delete "aeiou", "^e" \#=> "hell"
"hello"\.delete "ej\-m" \#=> "ho"
What does this mean?
I can't understand for the rules.
What it means is that it builds a character set performing the
intersection of all arguments to the method. So if you do
s.delete("h", "he") the intersection of the arguments is "h", because
it's the only one present in all arguments. If the arguments don't
intersect nothing is deleted:
"Any other_str that starts with a caret (^) is negated. The sequence
c1—c2 means all characters between c1 and c2. "
This means that s.delete("^aeiou") will remove all consonants and
leave the vocals, and that s.delete("a-m") will delete all characters
between "a" and "m":