“Ruby Cheat Sheet” Code-Antworten

Ruby Cheat Sheet

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

Bestes Ruby Cheat Sheet

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

Bestes Ruby Cheat Sheet

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

Bestes Ruby Cheat Sheet

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

Bestes Ruby Cheat Sheet

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

Bestes Ruby Cheat Sheet

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

Ähnliche Antworten wie “Ruby Cheat Sheet”

Fragen ähnlich wie “Ruby Cheat Sheet”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen