Skip to content

Instantly share code, notes, and snippets.

@100lp
Last active June 19, 2016 03:22
Show Gist options
  • Save 100lp/4740204 to your computer and use it in GitHub Desktop.
Save 100lp/4740204 to your computer and use it in GitHub Desktop.
If you prepend a constant with :: without a parent, the scoping happens on the topmost level. In this exercise, change push to return 10 as per A = 10 in the topmost level, outside the Kata module.module Kata
module Kata
A = 5
module Dojo
B = 9
A = 7
class ScopeIn
def push
ScopIn::A # (why if i write just "::A" - it work too ?)
end
end
end
end
A = 10
=======================
Kata::Dojo::ScopeIn.new.push should return 10
@okram999
Copy link

okram999 commented Nov 8, 2015

@rookie , if you want to have the test pass.

module Kata
A = 5
module Dojo
B = 9
A = 7

class ScopeIn
  def push
    10
  end
end

end
end

A = 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment