• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
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...
 
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!
 
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