Python Forum
an error --> a wanted feature
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an error --> a wanted feature
#10
Ruby has a feature that seems similar, where you can pass a block to a function. Not an annonymous function, but an actual block. Then, within the function, you can yield to that block. It's sort of like our iterators/generators, but is used for a whole lot of neat looking magic (like emulating with). http://ruby-doc.com/docs/ProgrammingRuby...rs.html#UD

def threeTimes
  yield
  yield
  yield
end
threeTimes { puts "Hello" }
produces:
Output:
Hello Hello Hello
Ok, I guess that's not really similar, it's just the first thing I thought of when it comes to functions doing different things depending on what happens "after" you call it.
Reply


Messages In This Thread
an error --> a wanted feature - by Skaperen - Nov-21-2017, 05:03 AM
RE: an error --> a wanted feature - by heiner55 - Nov-22-2017, 04:32 PM
RE: an error --> a wanted feature - by Skaperen - Nov-23-2017, 03:04 AM
RE: an error --> a wanted feature - by micseydel - Nov-22-2017, 04:46 PM
RE: an error --> a wanted feature - by heiner55 - Nov-22-2017, 04:56 PM
RE: an error --> a wanted feature - by heiner55 - Nov-23-2017, 06:19 AM
RE: an error --> a wanted feature - by wavic - Nov-23-2017, 09:18 AM
RE: an error --> a wanted feature - by Skaperen - Nov-24-2017, 01:43 AM
RE: an error --> a wanted feature - by micseydel - Nov-23-2017, 04:51 PM
RE: an error --> a wanted feature - by nilamo - Jan-04-2018, 07:19 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020