Skip to content

Instantly share code, notes, and snippets.

@guivinicius
Created February 18, 2014 01:08
Show Gist options
  • Select an option

  • Save guivinicius/9062623 to your computer and use it in GitHub Desktop.

Select an option

Save guivinicius/9062623 to your computer and use it in GitHub Desktop.

Revisions

  1. guivinicius created this gist Feb 18, 2014.
    52 changes: 52 additions & 0 deletions aula_1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    # Eu sou um comentario!
    #
    # Muito mais simples para entender depois!

    # Variaveis

    # Mais comuns
    var = "Sou uma variável local!"
    # @var = [1, "asd", "aaaaaa"]
    # VAR = 123

    # Menos comuns
    # @@var = "Sou uma variável de classe"
    # $var = "Sou uma variável global"

    # Tipos diferentes

    inteiro = 123
    float = 123.90
    string = "String"

    symbol = :text

    array = [1,2,3,4,5,[19,20],7,8,9,10]

    hash = {
    :text => "Muito obrigado",
    :values => [1,2,3, "aree"]
    }

    puts hash[:text]
    puts hash[:values].join(".")

    # Como declarar Métodos

    # Somos um método de instancia
    # def hello { return "Hello" }

    def hello
    return "Hello"
    end

    def hello
    "hello"
    end

    # Somos um metodo de classe
    def self.hello
    "hello"
    end

    # puts hello