Skip to content

Commit 1ecd378

Browse files
committed
Add a note about IndexError for String#[]
1 parent 868bee0 commit 1ecd378

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ Comparison:
734734

735735
##### `String#sub!` vs `String#gsub!` vs `String#[]=` [code](code/string/sub!-vs-gsub!-vs-[]=.rb)
736736

737+
Note that `String#[]` will throw an `IndexError` when given string or regexp not matched.
738+
737739
```
738740
$ ruby -v code/string/sub\!-vs-gsub\!-vs-\[\]\=.rb
739741
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

0 commit comments

Comments
 (0)