--- title: Ruby blurb: As the language that powers Middlemac, it’s worth taking a short look at the Ruby language. layout: template-logo-medium --- <%= md_links %> <%= md_images %> <%= current_page.data.title %> ============================== <%= current_page.data.blurb %> [Ruby](https://www.ruby-lang.org/en/) is the language that _Middlemac_, _Middleman_, and many of the others tools are written with. You do not have to learn Ruby to take advantage of _Middlemac_, although some ability to work with it will be invaluable to you. Ruby may surprise you --------------------- If you’re a software developer, then it’s highly likely that you will be able to read most Ruby code immediately. Coming from an Objective-C or Swift background, these are a few things that may surprise you. ### Symbols Ruby has a type of identifier called a `symbol`. They are used quite extensively and look like `:this_symbol`. As identifiers and not variables, you can’t assign values to them. Their value is themselves, though they have useful string representations (`:this_symbol.to_s`). You can even get the symbol representation of `'this_string'.to_sym`. Because they're unique, they make excellent array/hash keys and excellent, guaranteed unique values. ### Everything is an object Everything is an object, including what are fundamental datatypes in other languages. Need to convert the integer `i` to a float? It’s as easy as `i.to_f`. ### Everything has a return value In Ruby you don’t require `return value`, or `result := value`, or `function_name = value`. Just `value`, alone, will return its value. Even `if` statements return values: ~~~ ruby result = if answer == 'yes' "The answer as affirmative." else "The answer was something else." end ~~~ This example assigns the appropriate string to the variable `result`. Just enough Ruby ---------------- To work effectively with _Middlemac_ you’ll only have to learn enough Ruby to do a few simple things: - Set variables in the `config.rb` file. - Use a few helper functions from within files, e.g., `partial 'my_file'`. - Use conditionals, if you want them. You know: simply `if/else/end`, or even `unless/else/end`. Examples of these last two points can be seen when we take a look at [File Types][filetypes_skill].