Skip to content

Instantly share code, notes, and snippets.

@jcaristy
Last active September 20, 2017 22:57
Show Gist options
  • Save jcaristy/793aff5496ee18c13f85af56a4b59e12 to your computer and use it in GitHub Desktop.
Save jcaristy/793aff5496ee18c13f85af56a4b59e12 to your computer and use it in GitHub Desktop.
[RoR: Conceptos Basicos] #ruby

Variables

  • Global : $var
  • Class : @@var
  • Instance : @var
  • Local : var
  • Block : var

Obtener tipo de objeto

obj.class
"1".class

Formatear strings

nombre = "Juan"
puts "Hola #{nombre}"
puts "1+1=#{1+1}"

Validar si es nulo

x.nil?
[].empty?
[1].include?(1)
2.between?(3,4)
{"a" => "ax2"}.has_key?("a")
{"a" => "ax2"}.has_value?("ax2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment