<p>In Ruby 1.8 and earlier,</p>

<pre><code>Foo
</code></pre>

<p>is a constant (a Class, a Module, or another constant).  Whereas</p>

<pre><code>foo
</code></pre>

<p>is a variable.  The key difference is as follows:</p>

<pre><code>module Foo
  bar = 7
  BAZ = 8
end

Foo::BAZ
# =&gt; 8

Foo::bar
# NoMethodError: undefined method 'bar' for Foo:Module
</code></pre>

<p>That's all well and good, but Ruby 1.9 <a href="http://pragdave.blogs.pragprog.com/pragdave/2008/04/fun-with-ruby-1.html" rel="nofollow noreferrer">allows UTF-8 source code</a>.  So is <code>℃</code> "uppercase" or "lowecase" as far as this is concerned?  What about <code>⊂</code> (strict subset) or <code>Ɖfoo</code>?</p>

<p>Is there a general rule?</p>

<p><em>Later:</em></p>

<p>Ruby-core is already considering some of the mathematical operators.  For example</p>

<pre><code>module Kernel
  def √(num)
    ...
  end
  def ∑(*args)
    ...
  end
end
</code></pre>

<p>would allow</p>

<pre><code>x = √2
y = ∑(1, 45, ...)
</code></pre>

<p>I would love to see</p>

<pre><code>my_proc = λ { |...| ... }

x ∈ my_enumerable  # same as my_enumerable.include?(x)

my_infinite_range = (1..∞)

return 'foo' if x ≠ y

2.21 ≈ 2.2
</code></pre>

[{'answer_id': 23945, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 2, 'selected': False, 'text': "<p>I don't know what ruby would do if you used extended UTF8 characters as identifiers in your source code, but I know what I would do, which would be to slap you upside the back of the head and tell you DON'T DO THAT</p>\n"}, {'answer_id': 25592, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 2, 'selected': False, 'text': '<p>OK, my joking answer didn\'t go down so well.</p>\n\n<p><a href="http://www.nabble.com/String-upcase-downcase-with-UTF-8-strings-in-Ruby-1.9-td18372062.html" rel="nofollow noreferrer">This mailing list question, with answer from Matz</a> indicates that Ruby 1.9\'s built in <code>String#upcase</code> and <code>String#downcase</code> methods will only handle ASCII characters.</p>\n\n<p>Without testing it myself, I would see this as strong evidence that all non-ascii characters in source code will likely be considered lowercase.</p>\n\n<p>Can someone download and compile the latest 1.9 and see?</p>\n'}, {'answer_id': 25610, 'author': 'Julio César', 'author_id': 2148, 'author_profile': 'https://Stackoverflow.com/users/2148', 'pm_score': 1, 'selected': False, 'text': "<blockquote>\n  <p>I would love to see</p>\n</blockquote>\n\n<pre><code>my_proc = λ { |...| ... }\n\nx ∈ my_enumerable  # same as my_enumerable.include?(x)\n\nmy_infinite_range = (1..∞)\n\nreturn 'foo' if x ≠ y\n\n2.21 ≈ 2.2\n</code></pre>\n\n<p>I would love to see someone trying to type that program on an English keyboard :P</p>\n"}, {'answer_id': 1434830, 'author': 'James A. Rosen', 'author_id': 1190, 'author_profile': 'https://Stackoverflow.com/users/1190', 'pm_score': 1, 'selected': True, 'text': '<p>I can\'t get IRB to accept UTF-8 characters, so I used a test script (<code>/tmp/utf_test.rb</code>).</p>\n\n<p>"λ" works fine as a variable name:</p>\n\n<pre><code># encoding: UTF-8\nλ = \'foo\'\nputs λ\n\n# from the command line:\n&gt; ruby -KU /tmp/utf_test.rb\nfoo\n</code></pre>\n\n<p>"λ" also works fine as a method name:</p>\n\n<pre><code># encoding: UTF-8\nKernel.class_eval do\n  alias_method :λ, :lambda\nend\n\n(λ { puts \'hi\' }).call\n\n# from the command line:\n&gt; ruby -KU /tmp/utf_test.rb:\nhi\n</code></pre>\n\n<p>It doesn\'t work as a constant, though:</p>\n\n<pre><code># encoding: UTF-8\nObject.const_set :λ, \'bar\'\n\n# from the command line:\n&gt; ruby -KU /tmp/utf_test.rb:\nutf_test.rb:2:in `const_set\': wrong constant name λ (NameError)\n</code></pre>\n\n<p>Nor does the capitalized version:</p>\n\n<pre><code># encoding: UTF-8\nObject.const_set :Λ, \'bar\'\n\n# from the command line:\n&gt; ruby -KU /tmp/utf_test.rb:\nutf_test.rb:2:in `const_set\': wrong constant name Λ (NameError)\n</code></pre>\n\n<p>My suspicion is that constant names must start with a capital ASCII letter (must match <code>/^[A-Z]/</code>).</p>\n'}, {'answer_id': 4452015, 'author': 'Adriano Mitre', 'author_id': 525555, 'author_profile': 'https://Stackoverflow.com/users/525555', 'pm_score': 1, 'selected': False, 'text': '<p>In <strong>Ruby 1.9.2-p0 (YARV)</strong> the result is the same as in the original post (i.e., Foo::bar #=> # NoMethodError: undefined method \'bar\' for Foo:Module). Also, letters with accent are unfortunately not considered as being upper nor lower and related methods produce no result.</p>\n\n<p>Examples:</p>\n\n<pre><code>"á".upcase\n=&gt; "á"\n"á" == "Á".downcase\n=&gt; false\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/22764', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1190/']