通过阅读Rails问题列表,我无法找到%i对符号数组的影响。这对任何人都意味着什么吗?
答案 0 :(得分:15)
小写%i
代表
非插值符号数组,由空格分隔(在Ruby 2.0之后)
此外,大写%I
表示
插值符号数组,由空格分隔(在Ruby 2.0之后)
有关插值的差异示例:
2.4.2 :001 > a = 1
2.4.2 :002 > %i{one two #{a}+three} # Interpolation is ignored
=> [:one, :two, :"\#{a}+three"]
2.4.2 :003 > %I{one two #{a}+three} # Interpolation works
=> [:one, :two, :"1+three"]
请查看here以获取更多信息。
答案 1 :(得分:5)
我无法找到
class A { @Override public int hashCode() { return 1; } } class B { @Override public int hashCode() { return 1; } } // in some method HashMap<A, Object> map = new HashMap<>(); map.put(new A(), "some stuff"); map.get(new B()); // returns "someStuff"! makes no sense, right?
与符号数组相关的内容。
它是符号数组的数组文字。对于符号数组,它与%i
对字符串的作用相同。