• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Resource icon

Tutorial The Basics of the Ruby programming language 2018-06-23

Marin submitted a new resource:

The Basics of the Ruby programming language - This tutorial series covers the basics of Ruby. Absolute beginner-friendly.

The basics of the Ruby programming language

The purpose of this tutorial is to teach people who are new to Ruby or programming as a whole about some general programming concepts that apply to many more languages, but also about Ruby specifically. The clean syntax of Ruby will make it easier to understand everything and follow along with the tutorials.

Please note that there is so much more to Ruby than just what is covered here. These are merely the...

Read more about this resource...
 

Wonsul

Rookie
Member
Joined
Mar 27, 2018
Posts
8
Hey,

I have a question, not sure if this is me misunderstanding or an actual mistake : page 31/32, you show 2 methods for multiplying 2 data types together, if possible. At some point in both methods, it checks if "a" is a String or an Array, and then it checks if "b" is a Fixnum or a Float, and finally it does the calculation if both are True.
But just before that (still page 31), you say that "#String#*" and "Array#*" expect a Fixnum... Not a Float, so shouldn't the 2 methods fail to multiply if "b" is a Float?
 
Hey,

I have a question, not sure if this is me misunderstanding or an actual mistake : page 31/32, you show 2 methods for multiplying 2 data types together, if possible. At some point in both methods, it checks if "a" is a String or an Array, and then it checks if "b" is a Fixnum or a Float, and finally it does the calculation if both are True.
But just before that (still page 31), you say that "#String#*" and "Array#*" expect a Fixnum... Not a Float, so shouldn't the 2 methods fail to multiply if "b" is a Float?

What you said makes sense, because what I wrote down and what I actually gave as code isn't the same. The code is correct by allowing floats too, this normally works. I've edited the description to reflect that too, though - it did indeed say it only supported Fixnums, which isn't true.

Good catch!
 

Wonsul

Rookie
Member
Joined
Mar 27, 2018
Posts
8
What you said makes sense, because what I wrote down and what I actually gave as code isn't the same. The code is correct by allowing floats too, this normally works. I've edited the description to reflect that too, though - it did indeed say it only supported Fixnums, which isn't true.

Good catch!

Thanks for the clarification! But then ... What is the result if you multiply a String or an Array by a Float? Does it ignore the decimals?
 
Back
Top