Skip to content

Commit

Permalink
Promote KeyError to a first-class feature
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki24 committed Nov 22, 2017
1 parent 671cdff commit acf5945
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ first_name, last_name = full_name.split(" ")
# Did you mean? @@full_name
```

### NoMethodError
### Correcting a Method Name

```ruby
full_name = "Yuki Nishijima"
Expand All @@ -52,6 +52,15 @@ full_name.starts_with?("Y")
# Did you mean? start_with?
```

### Correcting a Hash key name

```ruby
hash = {foo: 1, bar: 2, baz: 3}
hash.fetch(:fooo)
# => KeyError: key not found: :fooo
# Did you mean? :foo
```

## Experimental Features

Aside from the basic features above, the `did_you_mean` gem comes with experimental features. They can be enabled by calling `require 'did_you_mean/experimental'`.
Expand All @@ -69,15 +78,6 @@ require 'did_you_mean/experimental'
# Did you mean? @full_name
```

### Correcting a Hash Key Name

```ruby
hash = {foo: 1, bar: 2, baz: 3}
hash.fetch(:fooo)
# KeyError: key not found: :fooo
# Did you mean? :foo
```

### Displaying a Warning When `initialize` is Incorrectly Typed

```ruby
Expand Down

0 comments on commit acf5945

Please sign in to comment.