News for hackers. Stuff that matters.
Re:Ruby 3.2.0 Is from Another Dimension by justin_oaks on Wednesday January 04, 2023 @12:17PM (#34248411)
For the benefit of those not familiar with the Python string interpolation/formatting situation, I present 4 ways to perform the same string formatting:

    who='World'
    #1 - string concatenation
    'Hello, ' + who + '!' 

    #2 - % operator
    'Hello, %s!' % who

    #3 - format() method
    'Hello, {}!'.format(who)

    #4 - f-strings
    f'Hello, {who}!'
Re:Ruby 3.2.0 Is from Another Dimension by jonnytran on Wednesday January 04, 2023 @02:29PM (#34250205)
Don't forget all the variations on how to use the format() method.

    # In order
    'Hello, {}!'.format(who)
    
    # Numbered
    'Hello, {0}!'.format(who)

    # Named
    'Hello, {name}!'.format(name = who)