One way I really like to write Ruby is to use an if statement after the code to be executed: def hey_ho? This else statement will be executed when the if expression is false: if 1 > 2ġ is not greater than 2, so the code inside the else statement will be executed. For example: if trueĢ is greater than 1, so the puts code is executed. If something is true, it executes what’s inside the statement. # booleansīook_price = 15.80 Conditional Statements: Control FlowĬonditional statements evaluate true or false. In the example above, a two variable stores an integer of 2 and some_number stores 10,000.īesides integers, we can also use booleans (true/false), strings, symbols, float, and other data types. You can assign a value to whatever variable you want. ![]() How simple was that? You just assigned the value 1 to a variable called one. Imagine you want to store the number 1 in a variable called one. In Ruby it’s easy to define a variable and set a value to it. You can think about a variable as a word that stores a value. Let’s get started with some basics! Variables It has an elegant syntax that is natural to read and easy to write.”. ![]() Ruby is “A dynamic, open source programming language with a focus on simplicity and productivity. The second - and main - reason is Rails: the same framework that Twitter, Basecamp, Airbnb, Github, and so many companies use. ![]() It’s natural to code and it always expresses my thoughts. “Ruby is simple in appearance, but is very complex inside, just like our human body.” - Matz, creator of the Ruby programming languageįor me, the first reason is that it’s a beautiful language.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |