“Folha de dicas para rubi” Respostas de código

Folha de dicas para rubi

Four good ruby cheat Sheets:
https://overapi.com/ruby
http://www.testingeducation.org/conference/wtst3_pettichord9.pdf
https://github.com/ThibaultJanBeyer/cheatsheets/blob/master/Ruby-Cheatsheet.md#basics
https://www.vikingcodeschool.com/professional-development-with-ruby/ruby-cheat-sheet
DevLorenzo

Melhor folha de dicas rubi

gets # is the Ruby equivalent to prompt in javascript (method that gets input from the user)
gets.chomp # removes extra line created after gets (usually used like this)
DevLorenz02

Melhor folha de dicas rubi

10.times do
  print “this text will appear 10 times”
end
DevLorenz02

Melhor folha de dicas rubi

things.each do |item| # for each things in things do something while storing that things in the variable item
  print “#{item}"
end
DevLorenz02

Melhor folha de dicas rubi

class DerivedClass < BaseClass; end # if you want to end a Ruby statement without going to a new line, you can just type a semicolon.

class DerivedClass < Base
  def some_method
    super(optional args) # When you call super from inside a method, that tells Ruby to look in the superclass of the current class and find a method with the same name as the one from which super is called. If it finds it, Ruby will use the superclass' version of the method.
      # Some stuff
    end
  end
end

# Any given Ruby class can have only one superclass. Use mixins if you want to incorporate data or behavior from several classes into a single class.
DevLorenz02

Melhor folha de dicas rubi

my_array = [a,b,c,d,e]
my_array[1] # b
my_array[2..-1] # c , d , e
multi_d = [[0,1],[0,1]]
[1, 2, 3] << 4 # [1, 2, 3, 4] same as [1, 2, 3].push(4)
DevLorenz02

Respostas semelhantes a “Folha de dicas para rubi”

Perguntas semelhantes a “Folha de dicas para rubi”

Procure respostas de código populares por idioma

Procurar outros idiomas de código