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 self.some_func | |
| end | |
| # now we can call this at the top-level | |
| p some_func #=> nil | |
| # without polluting Object | |
| p Object.new.respond_to?(:some_func, true) #=> false | |
| def some_object_polluting_func |
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
| module MyApp | |
| module Deeply | |
| module Nested | |
| module Namespace | |
| class Useful | |
| end | |
| class AlsoUseful | |
| 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
| module CallInstance | |
| def call(*args, &block) | |
| new(*args, &block).call | |
| end | |
| alias_method :[], :call | |
| 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
| p RUBY_VERSION #=> "2.0.0" | |
| require 'adamantium' | |
| require 'adamantium/version' # not required by default, oops! | |
| p Adamantium::VERSION #=> "0.1.0" | |
| class Something | |
| include Adamantium | |
| 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
| require 'benchmark' | |
| require 'ice_nine' | |
| def self.nested(depth, width, array_length) | |
| hash = {} | |
| 1.upto(width) do |n| | |
| hash[n.to_s] = n.to_s | |
| 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
| require 'unparser' | |
| original_verbosity = $VERBOSE | |
| $VERBOSE = nil | |
| Unparser::Emitter::REGISTRY = Unparser::Emitter::REGISTRY.dup | |
| $VERBOSE = original_verbosity | |
| module Rbfmt | |
| module Emitters | |
| # * Uses parens if the source did |
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
| jkjkio,6734t556b n b234534 |
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
| module Funcs | |
| module_function | |
| # functions ... | |
| 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
| user=> (take 10 (filter #(and (= 1 (mod % 2) (mod % 3) (mod % 4) (mod % 5) (mod % 6)) (= (mod % 7) 0)) (range))) | |
| (301 721 1141 1561 1981 2401 2821 3241 3661 4081) |
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
| module Functions | |
| module_function | |
| def state | |
| @state || ":-)" | |
| end | |
| def make_stateful! | |
| @state = ":-(" |