higher-order_functions.sf 241 B

1234567891011121314151617
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Higher-order_functions
  4. #
  5. func first(f) {
  6. return f();
  7. }
  8.  
  9. func second {
  10. return "second";
  11. }
  12.  
  13. say first(second); # => "second"
  14. say first(func { "third" }); # => "third"