Last active
December 18, 2022 21:41
-
-
Save blocknotes/94e9deb81a10bfc44fb28e39ebd3f9c0 to your computer and use it in GitHub Desktop.
Revisions
-
blocknotes revised this gist
Dec 18, 2022 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,5 +4,10 @@ def if(check, do:, else: nil) value.is_a?(Proc) ? value.call : value end ## Without block execution: # def if(check, do:, else: nil) # binding.local_variable_get(check ? :do : :else) # end self.if 5 < 10, do: 'Yes it is', else: 'Naaa' self.if 5 < 10, do: -> { 'Yes with a block' }, else: 'Naaa' -
blocknotes revised this gist
Dec 18, 2022 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,8 @@ def if(check, do:, else: nil) result = check ? :do : :else value = binding.local_variable_get(result) value.is_a?(Proc) ? value.call : value end self.if 5 < 10, do: 'Yes it is', else: 'Naaa' self.if 5 < 10, do: -> { 'Yes with a block' }, else: 'Naaa' -
blocknotes renamed this gist
Dec 18, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
blocknotes created this gist
Dec 18, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ def if(check, do:, else: nil) binding.local_variable_get(check ? :do : :else) end self.if 5 < 10, do: 'Yes it is', else: 'Naaa'