Ruby Format Strings
1 2 '<p id="%d" class="%s">%s</p>' % [ 3 @node.id, 4 @node.class, 5 @node.value, 6 ]
DZone Snippets > warona > string
12723 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 '<p id="%d" class="%s">%s</p>' % [ 3 @node.id, 4 @node.class, 5 @node.value, 6 ]
1 2 a = [ "xxEins", "xxZwei", "xxDrei" ] 3 4 a.each do |s| 5 s.replace( s[2..-1] ) 6 end 7 8 p a # >> ["Eins", "Zwei", "Drei"]