Issue #6012 has been updated by Thomas Sawyer.


Would this effect Method#source_location too?

I'm not sure I am really digging this idea. First of all it means I have to go back and fix some code. Secondly it means I have to always worry about the additional piece of data even though most of the time it doesn't matter. And if the return can vary between 2 or 3 elements that's another thing to worry with.

On the other hand I can understand that it could be useful information in some cases.

In times like this that I think "Embrace the Object".

  proc.source_location  #=>  #<SourceLocation @file="foo.rb" @line=12 @column=14>

And then a few different methods could provide that information in various useful forms.

  proc.source_location.to_a  #=>  ["foo.rb", 12, 14]
  proc.source_location.to_s  #=>  "foo.rb:12"
  proc.source_location.values_at(:file, :line)  #=>  ["foo.rb", 12]

Or what have you.
----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: core
Target version: 2.0.0


As originally suggested in http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/42418

Suggestion/feature request:
have #source_location also return the beginning column where it was defined.
["test.rb", 8, 33]

Thanks!
-roger-



-- 
http://bugs.ruby-lang.org/