Skip to content
Open
Changes from all 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
15 changes: 9 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,14 @@ <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`.
</script>
</section>
<section class="slide" data-markdown>
Expand Down Expand Up @@ -421,7 +424,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 +438,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 +517,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 +1024,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