Add "Correct Usage" and "Incorrect Usage" headings

This commit is contained in:
Owen Mansel-Chan
2025-06-26 14:33:37 +01:00
parent 9521994adc
commit 9f0f40d6ce
4 changed files with 24 additions and 1 deletions

View File

@@ -11,6 +11,8 @@ Note: You do not need to explicitly initialize the variable, if you can make the
## Example
### Incorrect Usage
In the following code, the call to `create_file` may fail and then the call `f.close` will raise a `NoMethodError` since `f` will be `nil` at that point.
```ruby
@@ -22,6 +24,8 @@ ensure
end
```
### Correct Usage
We can fix this by using safe navigation:
```ruby
def dump(x)