From the Ruby world, I immediately understood why Crystal decided not to use the method for. But then I was surprised to see that Crystal implements a method forfor macros. I was even more surprised to find that macros do not allow an enumerable ( .eachetc.) syntax (i.e., is {% ["one", "two", "three"].each do |value| %}not a valid macro syntax).
for
.each
{% ["one", "two", "three"].each do |value| %}
Is there a logical reason for this difference in syntax? Perhaps the answer is simply “because the developers decided that the macro syntax looks like x and the non-macro syntax looks like y,” but I assume there is something else in it (arbitrary syntax inconsistency seems to be a drawback).
Thank!
, foo.bar do |arg| ... end, |arg|, %}, . , , ( ). for - , , , , ( ).
foo.bar do |arg| ... end
|arg|
%}
, each , while until? , for , . ... , run .
each
while
until
run
, , each, each_with_index .., , , for . , , .
each_with_index
Source: https://habr.com/ru/post/1691553/More articles:Why does array + = (without @.) Create so much memory? - julia-langПочему Вулькан не использует "стандартную декартовую" систему координат? - designWindows UTF-8 printed with chcp 65001 - characters mysteriously duplicated - windowsUnable to read property of undefined function inside loop - javascriptMySQL performance in a large write-only table - sqlКак я могу лучше всего "параллелизовать" набор из четырех вложенных for() - циклов в атаке Brute-Force? - cGeolocation And Custom Google Maps API Token - javascriptCreating an Indexed Ordered Map - c ++Chart.js corner line - javascriptПреобразование столбца типа списка в длинную форму путем разделения элементов - splitAll Articles