Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutate module or class constant #30

Closed
dkubb opened this issue Feb 17, 2013 · 1 comment
Closed

Mutate module or class constant #30

dkubb opened this issue Feb 17, 2013 · 1 comment

Comments

@dkubb
Copy link
Collaborator

dkubb commented Feb 17, 2013

This is an edge case, but the following code has identical behaviour, provided the same-named method isn't declared in that scope:

Kernel.system(...)
system(...)

@mbj I know you've said you prefer the first one for understandability. I think if the code works the same with less information, then the other should be preferred.

The same rule can be applied to self.class, eg:

class MyClass < ParentClass
  def call(*args)
    self.class.call(*args)
  end

  def one
    self.class.call(1)
  end
end

In this example the self.class could be removed in #one and the code would continue to work.

@mbj
Copy link
Owner

mbj commented Feb 17, 2013

Yeah, you are correct. "Least powerful rule" ;)

Will change it.

On Sat, Feb 16, 2013 at 11:18:14PM -0800, Dan Kubb wrote:

This is an edge case, but the following code has identical behaviour, provided the same-named method isn't declared in that scope:

Kernel.system(...)
system(...)

@mbj I know you've said you prefer the first one for understandability. I think if the code works the same with less information, then the other should be preferred.

The same rule can be applied to self.class, eg:

class MyClass < ParentClass
  def call(*args)
    self.class.call(*args)
  end

  def one
    self.class.call(1)
  end
end

In this example the self.class could be removed in #one and the code would continue to work.


Reply to this email directly or view it on GitHub:
#30

Markus Schirp

Phone: +49 201 / 360 379 14
Fax: +49 201 / 360 379 16
Web: www.seonic.net
Email: mbj@seonic.net
Twitter: twitter.com/m_b_j
OS-Code: github.com/mbj

Seonic IT-Systems GbR
Anton Shatalov & Markus Schirp
Altendorferstrasse 44
D-45127 Essen

@mbj mbj closed this as completed in ddff94c Jun 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants