I was recently doing some work on documenting and adding some missing typespecs to the Elixir codebase, and in that work I saw something that I thought I could improve. def default_options do [ enabled: true, doc_bold: [:bright], doc_code: [:cyan], doc_headings: [:yellow], doc_inline_code: [:cyan], doc_table_heading: [:reverse], doc_title: [:reverse, :yellow], doc_underline: [:underline], width: 8
defmodule OnDefinition do def on_definition(env, _kind, _name, _args, _guards, _body) do Module.put_attribute(env.module, :my_func_attr, nil) end end defmodule Foo do # Foo モジュール内で関数を定義したタイミングで呼ばれるフックを指定する。 @on_definition {OnDefinition, :on_definition} # これをモジュール定義の最初のほうで実行すると、 # 以降このモジュール内に出現した `@my_func_attr expr` が記録されていく。 # このモジュールのコンパイルフェーズ中に限り、 # `Module.get_attribute(Foo, :my_func_attr)` マク
この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。 出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方) 出典検索?: "定数" プログラミング – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL (2019年6月) プログラミングにおいて定数(「ていすう」または「じょうすう」、英: constant)とは、変数同様プログラムのソースコードにおいて、扱われるデータを一定期間記憶し必要なときに利用できるようにするために、データに固有の名前を与えたものである。 ただし変数とは異なり、一度初期化するとその内容(値)を変更することはできない。よって、内容が変化しないことが保証される名前が必要なときに使用される。 ソースコードに直接記述するデータ(リテラル)のことを指して
A class variableIn addition, Ruby has two pseudo-variables which cannot be assigned values. These are nil which is assigned to uninitialized variables and self which refers to the currently executing object. In the remainder of this chapter we will look at each of these variable scopes in turn. Detecting the Scope of a Ruby VariableObviously, you can tell the scope of a variable by looking at the
JITTY's seasoned experts specialize in identifying optimal solutions to address your business challenges. Our proficiency in pioneering video and live interactive technologies ensures tailored strategies that effectively resolve tasks, delivering seamless experiences and driving your business forward.
gold対策。 class C def foo CONST = 'aaa' end end # ~> -:3: dynamic constant assignment # ~> CONST = 'aaa' # ~> これは単純に知らなかったのですが、メソッド内で定数は定義できません。 (基礎力確認問題5)こっちはエラー内容は同じですが メソッド内にて定数を変更しようとしているところでエラーとなっています。 (コメントもらって、subjectに合わせて内容修正しました。thanks) $ cat -n k05.rb 1 #!/usr/bin/env ruby -w 2 class C 3 VAR = 0 4 def VAR= v 5 VAR= v 6 end 7 def VAR 8 VAR 9 end 10 end 11 12 c = C.new 13 c.VAR = 3 14 puts c
PRs, Commits, and Code Reviews Published at 2026-02-17 16:32:54 -0800 This is a post I wrote while I was at zendesk that I thought would be good to share with the world. This is a conversation that I had to have over and over and over again while reviewing PRs that were switched from draft to non-draft, which is why I eventually wrote this up: PRs, Commits, and Code Reviews Developers, Reviewers,
DATA -> File[permalink][rdoc] スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。 プログラム・文・式/プログラムの終りも参照。 ソースファイルの __END__ 以降は解析・実行の対象にならないので その部分にプログラムが利用するためのデータを書き込んでおくことができます。 DATA 定数はそのデータ部分にアクセスするための File オブジェクトを保持しています。 __END__ を含まないプログラムにおいては DATA は定義されません。 注意 DATA.rewind で移動する読みとり位置は __END__ 直後ではなく、 スクリプトファイルの先頭です。 スクリプトが標準入力から読みこまれた場合は標準入力になります。 スクリプトがファイルや標準入力から読みこまれなかった場合や、 __END__ で終っていない場合に
2013-01-08 19:09:42In a ruby script, there’s a keyword __END__ that for a long time I thought just marked anything after it as a comment. So I used to use it to store snippets and notes about the script that weren’t really needed inline. Then one day I stumbled across the DATA constant, and wondered what flaming magic it was. DATA is in fact an IO object, that you can read from (or anything else y
const_missing(name)[permalink][rdoc][edit] 定義されていない定数を参照したときに Ruby インタプリタがこのメソッドを呼びます。 [PARAM] name: 参照した定数名の Symbol [EXCEPTION] NameError: このメソッドを呼び出した場合、デフォルトで発生する例外 例 class Foo def Foo.const_missing(id) warn "undefined constant #{id.inspect}" end Bar end Foo::Bar # => undefined constant :Bar # undefined constant :Bar
この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。 出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方) 出典検索?: "数学定数" – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL (2016年8月) 数学定数(すうがくていすう)とは、数学においてよく現れる定まった数の事。これらの定数は頻繁に現れるか(数学者にとっては)非常に興味深いため、決まった文字で書き著す慣習がある。尚変数を斜体で表すのに対して定数を立体で表す[要出典]。 特に、以下の5つは頻繁に現れる。 円周率 、自然対数の底 、虚数単位 、黄金比 、オイラーの定数 ほかの代表的かつ理解しやすい例は実数体か複素数体の元である。 上記の例と同じく、基本的に明確な定義を持つ。だが存在しているか分からない
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く