一方の言語でのイメージが邪魔して、もう一方の言語での書き方が思い出せない時がたまにあるんです。
Python
map(lambda n: str(n).rjust(3,"0"), [1,2,3])
>> ["001", "002", "003"]
Ruby
[1,2,3].map{|n| n.to_s.rjust(3,"0")}
>> ["001", "002", "003"]
Go to list of users who liked
More than 3 years have passed since last update.
一方の言語でのイメージが邪魔して、もう一方の言語での書き方が思い出せない時がたまにあるんです。
map(lambda n: str(n).rjust(3,"0"), [1,2,3])
>> ["001", "002", "003"]
[1,2,3].map{|n| n.to_s.rjust(3,"0")}
>> ["001", "002", "003"]
Register as a new user and use Qiita more conveniently
Go to list of users who liked