guides/src/getting-started/getting-started.md in steep-1.6.0 vs guides/src/getting-started/getting-started.md in steep-1.7.0.dev.1
- old
+ new
@@ -14,28 +14,28 @@
```
$ bundle install
```
-You can install it with the gem command.
+Alternatively, you can install it with the gem command.
```
$ gem install steep
```
Execute the following command to confirm if the command is successfully installed.
```
$ steep version
-$ bundle exec steep version # When you install with bundler
+$ bundle exec steep version # If you install with bundler
```
-We omit the `bundle exec` prefix from the following commands. Run commands with the prefix if you install Steep with bundler.
+We omit the `bundle exec` prefix from the following commands. Run commands with the prefix if you installed Steep with Bundler.
## Type checking your first Ruby script
-Run steep init command to generate the configuration file, Steepfile.
+Run the `steep init` command to generate the configuration file, `Steepfile`.
```
$ steep init
```
@@ -52,11 +52,11 @@
```rb
currencies = { US: "$", JP: "¥", UK: "£" }
country = %w(US JP UK).sample()
-puts "Hello! The price is #{currencies[country.to_sym]}100. 💸"
+puts "Hello! The price is #{currencies[country]}100. 💸"
```
And type check it with Steep.
```
@@ -82,17 +82,17 @@
~~~~~~~
Detected 1 problem from 1 file
```
-The error says that the type of the country variable causes a type error. It is expected to be a Symbol, but String or nil will be given.
+The error says that the type of the country variable causes a type error. It is expected to be a symbol, but string or `nil` will be given.
Let's see how we can fix the error.
## Fixing the type error
-The first step is converting the string value to a symbol. We can add to_sym call.
+The first step is converting the string value to a symbol. We can add a `#to_sym` call.
```rb
currencies = { US: "$", JP: "¥", UK: "£" }
country = %w(US JP UK).sample()
@@ -126,28 +126,28 @@
# Satisfying the type checker by adding a guard
The underlying type system supports flow-sensitive typing similar to TypeScript and Rust. It detects conditional expressions testing the value of a variable and propagates the knowledge that the value cannot be `nil`.
-We can fix the type error with an or construct.
+We can fix the type error with an `or` construct.
```rb
currencies = { US: "$", JP: "¥", UK: "£" }
country = %w(US JP UK).sample() or raise
puts "Hello! The price is #{currencies[country.to_sym]}100. 💸"
```
-The change let the type checking succeed.
+The change lets the type checking succeed.
```
$ steep check
# Type checking files:
.........................................................
-No type error detected. 🧉
+No type error detected. 🫖
```
The `raise` method is called when `sample()` returns `nil`. Steep can reason the possible control flow based on the semantics of or in Ruby:
* The value of `country` is the return value of `sample()` method call
@@ -159,6 +159,5 @@
There are two possibilities of the type of the result of the `sample()` call, `nil` or a string. We humans can reason that we can safely ignore the case of `nil`. But, the type checker cannot. We have to add `or raise` to tell the type checker it can stop considering the case of `nil` safely.
## Next steps
This is a really quick introduction to using Steep. You may have noticed that I haven't explained anything about defining new classes or modules. See the RBS guide for more examples!
-