Skip to content

Commit ac31d48

Browse files
committed
to-ruby-from-python functional programming
Added one bullet point of similarities and two of differences, regarding functional programming, in to-ruby-from-python/index.md
1 parent cb1f900 commit ac31d48

File tree

1 file changed

+9
-0
lines changed
  • en/documentation/ruby-from-other-languages/to-ruby-from-python

1 file changed

+9
-0
lines changed

en/documentation/ruby-from-other-languages/to-ruby-from-python/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ As with Python, in Ruby,...
2727
* Although the keywords are a bit different, exceptions work about the
2828
same.
2929
* You’ve got embedded doc tools (Ruby’s is called rdoc).
30+
* There is good support for functional programming with first-class
31+
functions, anonymous functions, and closures.
3032

3133
### Differences
3234

@@ -71,4 +73,11 @@ Unlike Python, in Ruby,...
7173
statement). You can reset a variable to `nil`, allowing the old
7274
contents to be garbage collected, but the variable will remain in the
7375
symbol table as long as it is in scope.
76+
* The `yield` keyword behaves differently. In Python it will return
77+
execution to the scope outside the function's invocation. External
78+
code is responsible for resuming the function. In Ruby `yield` will
79+
execute another function that has been passed as the final argument,
80+
then immediately resume.
81+
* Python supports just one kind of anonymous functions, lambdas, while
82+
Ruby contains blocks, Procs, and lambdas.
7483

0 commit comments

Comments
 (0)