4259 links
  • Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
search: tag:ruby tag:hash — newest first
  • methods - How do functions use hash arguments in Ruby? - Stack Overflow

    L'appel d'une fonction peut se faire avec ou sans parenthèse :

    foo() ou foo

    Ensuite, un Hash peut avoir plusieurs formes..

    {'a' => 12}
    où 'a' peut être n'importe quoi : string (comme ici), mais aussi objet,
    symbol : exemple :
    {:a => 12}

    La nouvelle syntaxe, valable uniquement si les clés sont des symboles :

    {a: 12, b: 'toto'}

    Et enfin quand on call une méthode qui peut prendre un hash en argument (entre autre), pas besoin de mettre les { }

    foo({a: 12, b:14})
    ou
    foo(a: 12, b:14)
    ou
    foo a: 12, b:14

    August 10, 2015 - permalink - http://stackoverflow.com/questions/16576477/how-do-functions-use-hash-arguments-in-ruby
    arguments hash named rails ruby syntax