我有一个地图,其中键(一个字符串)可以有非常可变的字符数,我想智能地打印它:
MAP = {
"key1" => "value1",
"key2" => "value2",
}
会打印:
key1 -> value1
key2 -> value2
和
MAP = {
"key1" => "value1",
"key2" => "value2",
"key3_dam_it_you_are_a_big_one_indeed" => "value3",
}
会打印:
key1 -> value1
key2 -> value2
key3_dam_it_you_are_a_big_one_indeed -> value3
他的想法是key1和key2会根据key3的大小改变它们的打印行。
谢谢!