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 characters
// in React after 15.6 | |
const triggerInputChange = (node, value = '') => { | |
const inputTypes = [ | |
window.HTMLInputElement, | |
window.HTMLSelectElement, | |
window.HTMLTextAreaElement | |
]; | |
if (inputTypes.indexOf(node.__proto__.constructor) > -1) { |
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 characters
(->{ puts "Hey, I'm IIFE" }).() |
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 characters
send def execute_right_now | |
puts "That's nice!" | |
end |
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 characters
some_method def another_method; end |
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 characters
class RailsController | |
helper_method def current_user | |
User.current | |
end | |
end |
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 characters
send def escape | |
return "I want to return" | |
ensure | |
puts "print this text first" | |
end | |
# Output looks like this: | |
print this text first | |
=> "I want to return" |
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 characters
send def escape | |
return "I want to return" | |
ensure | |
return "I want to finally get out" | |
end | |
=> "I want to finally get out" |
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 characters
status, reason = send def authorize | |
response = do_request | |
if response.success? | |
return :ok, response.body | |
else | |
return :error, response.error | |
end | |
end |
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 characters
return [:ok, response.body] | |
# or | |
[:ok, response.body] |
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 characters
go_deeper.call.call.call.call.call.call.call.call | |
# You can try to implement it yourself. Your code will look like this: | |
(go_deeper = -> { puts "deeper"; go_deeper }).call.call.call.call.call |