A
August Lilleaas
I got this idea of a sort of neat syntatic sugar of bang (foo!) and
question (foo?) methods. Take a look at this pastie:
http://pastie.caboo.se/98638
The idea is that you'll have two keywords added to Ruby - bang_given?
and question_given?. Similar to block_given?.
In this pastie, the method "finish" will not call save, as bang_given?
isn't true. If you call "finish!", though, b ang_given will return true,
and save will be called.
Same thing with question_given?. Question given would be the least
useful of them, though.
And yes, doing def finish!; finish; save; is pretty easy, and this is
not the sort of thing that should have max priority. It would still be a
nice addition to the code-design useability of Ruby, though, as having
10 "def finish!; finish; save;"-ish methods is pretty boring.
(And yes, looping and define_method, too, but still!)
question (foo?) methods. Take a look at this pastie:
http://pastie.caboo.se/98638
The idea is that you'll have two keywords added to Ruby - bang_given?
and question_given?. Similar to block_given?.
In this pastie, the method "finish" will not call save, as bang_given?
isn't true. If you call "finish!", though, b ang_given will return true,
and save will be called.
Same thing with question_given?. Question given would be the least
useful of them, though.
And yes, doing def finish!; finish; save; is pretty easy, and this is
not the sort of thing that should have max priority. It would still be a
nice addition to the code-design useability of Ruby, though, as having
10 "def finish!; finish; save;"-ish methods is pretty boring.
(And yes, looping and define_method, too, but still!)