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
a = [1,2,3, nil] | |
if a[0] | |
puts a[0] + 1 # This doesn't work | |
end | |
puts a[0].not_nil! + 1 # This does though |
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
a = [1,2,3, nil] | |
b = a.first | |
if b # Create a branch of nil/not_nil | |
puts b + 1 | |
else | |
puts "B is nil" | |
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
def method_missing(name, *args) | |
args.reduce {|a,b| a + b } | |
end | |
puts(sum 1,2,3,4,5) |
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
macro method_missing(call) | |
{{call.args}}.reduce {|a,b| a + b } | |
end | |
puts(sum 1,2,3,4,5) |
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
macro example | |
%a = 5 | |
a = %a + a | |
end | |
a = 4 | |
example | |
print(a) // Prints 9 |
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
function parseExtensionCommands( | |
extensions: Extension<any>[] | |
): CommandOption[] { | |
let options: CommandOption[] = []; | |
extensions.forEach(ext => { | |
let { | |
packageJSON: { contributes: { commands } = { commands: [] } } | |
} = ext; | |
if (commands) { | |
commands.forEach((c: Command) => { |
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
vscode.commands.executeCommand(list.activeItems[0].command.command) |
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
def copy(text) | |
IO.popen('pbcopy', 'w') {|f| f << text} | |
end | |
class Array | |
def to_c | |
copy map(&:to_s).join("\n") | |
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
puts 14.upto(18).map {|e| "Week #{e}" } |
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
14.upto(18).map {|e| "Week #{e}" }.to_c |