A place where we can put hopefully useful content that may or may not have a structural home yet. we'll post things here in a hap-hazard fashion to give ya'll access to them before we figure out exactly what to do with it.
elements = [ 1,2,3,4,"home", ["nested-array"], {:key => "value"} ]
for element in elements do
p element
p element.class
end
Click here to watch a screencast on iteration with a for loop.
http://guides.rubygems.org/make-your-own-gem/
Ruby coders expect code to use indentation settings based on 'soft-tabs'. 'Soft-tabs' means that a tab character is translated to two spaces. It is difficult to control for how to attain this state with all coding editors but the below screenshots demonstrate the how to attain this state with Sublime Text 3. 👍
You can use the handy Spaces
dialogue tab in any normal Sublime window pane like the below.
If you want to verify you set your indentation correctly:
Head to Sublime Text => Preferences => Settings - User
Which will open a file that looks like:
You want to make sure your Preferences.sublime-settings
file has at least the below lines. It may have other stuff too, that is fine.
{
"tab_size": 2,
"trim_trailing_white_space_on_save": true,
}
For more on how sublime settings work, read sublime settings.
If you find yourself writing things like
some_variable = Hash.new
# or
some_other_variable = Array.new
Consider using the Object Literal like the below.
some_variable = {}
# or
some_other_variable = []