C# to Ruby String Interpolation
Working with strings is part and parcel of any programming language. In C#, we use String.Format to do a lot of interpolation and manipulation. Here is a simple example using C#
Now how do we accomplish the same thing in Ruby?
From this code you see we are not using a position within our string to specify what variable goes where, we do this explicitly +1. You can define a method, in the middle of this string! What you might see here is that you need to use double quotes (“) and you use the hash / pound / number sign with curly braces to define a variable. There isn’t too much else to mention here. It’s pretty straight-forward and to me it seems like a better way to add your variables within the string since you don’t need to worry about positioning.
Ruby strikes again! Again I see that Ruby wants you to use fewer key strokes and be more explicit about what you want to do. What an awesome language!