Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions slides.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ <h2>Part 2</h2>

We just used the *integer* number **class** but there are many more.

* Integer/Fixnum (whole numbers)
* Integer (whole numbers)
* Float (numbers containing decimals)
* String (words, sentences, literal text) - requires quotes
* Boolean (`true`, `false`)
Expand All @@ -302,11 +302,15 @@ <h2>Part 2</h2>
=> String

irb> 42.class
=> Fixnum
=> Integer

irb> 3.14159.class
=> Float
```

Heads up! Older versions of Ruby call it `Fixnum` instead of
`Integer`. For the purposes of this workshop, whenever you see
`Integer` in your code, you can safely replace it with `Fixnum`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest dropping this second sentence from the slides to keep it brief.

</script>
</section>
<section class="slide" data-markdown>
Expand Down Expand Up @@ -421,7 +425,7 @@ <h2>Part 2</h2>

```ruby
irb> puts 2 + "2"
TypeError: String cannot be coerced into Fixnum
TypeError: String cannot be coerced into Integer

```
</script>
Expand All @@ -435,7 +439,7 @@ <h2>Part 2</h2>

```ruby
irb> puts 2 + "2"
TypeError: String cannot be coerced into Fixnum
TypeError: String cannot be coerced into Integer
```

* The first `2`, inside of `puts 2 + "2"` is an integer.
Expand Down Expand Up @@ -514,7 +518,7 @@ <h2>Part 2</h2>

```
irb> puts 3 + " items in my bento!"
TypeError: String cant be coerced into Fixnum
TypeError: String cant be coerced into Integer

```
Use the `.to_s` method to convert a number to a string.
Expand Down Expand Up @@ -1021,7 +1025,7 @@ <h2>Part 2</h2>
```

```ruby
irb> if x.class == Float || x.class == Fixnum
irb> if x.is_a?(Float) || x.is_a?(Integer)
... puts "x is a numeric value"
... end
x is a numeric value
Expand Down