Это улучшает принятый ответ:
.box {
margin-top: 1em;
margin-bottom: 1em;
background-color: #CCC;
}
.fixed-ar::before {
content: "";
float: left;
width: 1px;
margin-left: -1px;
}
.fixed-ar::after {
content: "";
display: table;
clear: both;
}
.fixed-ar-16-9::before {
padding-top: 56.25%;
}
.fixed-ar-3-2::before {
padding-top: 66.66%;
}
.fixed-ar-4-3::before {
padding-top: 75%;
}
.fixed-ar-1-1::before {
padding-top: 100%;
}
.width-50 {
display: inline-block;
width: 50%;
}
.width-20 {
display: inline-block;
width: 20%;
}
<div class="box fixed-ar fixed-ar-16-9">16:9 full width</div>
<hr>
<div class="box fixed-ar fixed-ar-16-9 width-50">16:9</div>
<hr>
<div class="box fixed-ar fixed-ar-16-9 width-20">16:9</div>
<div class="box fixed-ar fixed-ar-3-2 width-20">3:2</div>
<div class="box fixed-ar fixed-ar-4-3 width-20">4:3</div>
<div class="box fixed-ar fixed-ar-1-1 width-20">1:1</div>
<hr>
<div class="box fixed-ar fixed-ar-16-9 width-20">16:9</div>
<div class="box fixed-ar fixed-ar-16-9 width-50">16:9</div>
I can't get IRB to accept UTF-8 characters, so I used a test script (/tmp/utf_test.rb
).
"λ" works fine as a variable name:
# encoding: UTF-8
λ = 'foo'
puts λ
# from the command line:
> ruby -KU /tmp/utf_test.rb
foo
"λ" also works fine as a method name:
# encoding: UTF-8
Kernel.class_eval do
alias_method :λ, :lambda
end
(λ { puts 'hi' }).call
# from the command line:
> ruby -KU /tmp/utf_test.rb:
hi
It doesn't work as a constant, though:
# encoding: UTF-8
Object.const_set :λ, 'bar'
# from the command line:
> ruby -KU /tmp/utf_test.rb:
utf_test.rb:2:in `const_set': wrong constant name λ (NameError)
Nor does the capitalized version:
# encoding: UTF-8
Object.const_set :Λ, 'bar'
# from the command line:
> ruby -KU /tmp/utf_test.rb:
utf_test.rb:2:in `const_set': wrong constant name Λ (NameError)
My suspicion is that constant names must start with a capital ASCII letter (must match /^[A-Z]/
).
Хорошо, мой шуточный ответ не понижался так хорошо.
Этот вопрос о списке рассылки, с ответом от Matz указывает, что Ruby 1.9's встроил String#upcase
и String#downcase
методы только обработают символы ASCII.
Не тестируя его самостоятельно, я рассматривал бы это как убедительные доказательства, что все символы неASCII в исходном коде будут, вероятно, считать нижним регистром.
Кто-то может загрузить и скомпилировать последние 1.9 и видеть?
Я хотел бы видеть
my_proc = λ { |...| ... }
x ∈ my_enumerable # same as my_enumerable.include?(x)
my_infinite_range = (1..∞)
return 'foo' if x ≠ y
2.21 ≈ 2.2
Я хотел бы видеть, что кто-то пытается ввести ту программу на английской клавиатуре :P
Я не знаю то, что сделал бы рубин, если бы Вы использовали расширенные символы UTF8 в качестве идентификаторов в Вашем исходном коде, но я знаю то, что я сделал бы, который должен будет хлопнуть Вас позитивный аспект затылок и сказать, что Вы не ДЕЛАЕТЕ ЭТОГО