[前][次][番号順一覧][スレッド一覧]

ruby-changes:49900

From: kazu <ko1@a...>
Date: Wed, 24 Jan 2018 09:03:58 +0900 (JST)
Subject: [ruby-changes:49900] kazu:r62018 (trunk): Add documentation for the Kernel#warn :uplevel keyword

kazu	2018-01-24 09:03:51 +0900 (Wed, 24 Jan 2018)

  New Revision: 62018

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62018

  Log:
    Add documentation for the Kernel#warn :uplevel keyword
    
    [ruby-core:84574] [Bug #14264]
    Author:    Jeremy Evans <code@j...>

  Modified files:
    trunk/error.c
Index: error.c
===================================================================
--- error.c	(revision 62017)
+++ error.c	(revision 62018)
@@ -323,6 +323,25 @@ warning_write(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/error.c#L323
  *
  *    warning 1
  *    warning 2
+ *
+ * If the <code>:uplevel</code> keyword is given, the string will
+ * be prepended with information for the given caller frame in
+ * the same format used by the <code>rb_warn</code> C function.
+ *
+ *    # In baz.rb
+ *    def foo
+ *      warn("invalid call to foo", uplevel: 1)
+ *    end
+ *
+ *    def bar
+ *      foo
+ *    end
+ *
+ *    bar
+ *
+ *  <em>produces:</em>
+ *
+ *    baz.rb:6: warning: invalid call to foo
  */
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]