Skip to content

Instantly share code, notes, and snippets.

@yaf
Last active October 12, 2020 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaf/6cea8b4089e9fb355d2bcf20a1893560 to your computer and use it in GitHub Desktop.
Save yaf/6cea8b4089e9fb355d2bcf20a1893560 to your computer and use it in GitHub Desktop.
begin
phrase("Henri")
rescue
puts "erreur, la fonction phrase() n'existe pas encore"
end
require "./une_lib"
puts "Hello depuis le fichier executé : hello.rb"
phrase("Henri")
puts "Coucou depuis une lib où on va définir une fonction qui renvoie une phrase"
def phrase(nom)
"Bonjour #{nom}, comment vas-tu ?"
end
@vinyll
Copy link

vinyll commented Oct 12, 2020

En Crystal, ca donne ce résultat :

➜  hello crystal hello.cr
Showing last frame. Use --error-trace for full trace.

In hello.cr:2:10

 2 | phrase(nom)
            ^--
Error: undefined local variable or method 'nom' for top-level

@vinyll
Copy link

vinyll commented Oct 12, 2020

En modifiant nom en "nom", ca donne ça :

➜  hello crystal hello.rb
Coucou depuis une lib où on va définir une fonction qui renvoie une phrase
Hello depuis le fichier executé : hello.rb

@vinyll
Copy link

vinyll commented Oct 12, 2020

En Ruby par contre :

➜  hello ruby hello.rb
erreur, la fonction phrase() n'existe pas encore
Coucou depuis une lib où on va définir une fonction qui renvoie une phrase
Hello depuis le fichier executé : hello.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment