One of my favorite patterns:
_, username, domain = */([^@]+)@(.+$)/.match("foo@example.com") _, username, domain = */([^@]+)@(.+$)/.match("foo@example.com")FWIW, I personally prefer the #match method. Some of the examples in this article just make me want to hurt people. Especially usage of $1, $2, etc.
username, domain = */([^@]+)@(.+$)/.match("foo@example.com").captures
Of course, your string better match, otherwise you'll get a NoMethodError. username, domain = [*/([^@]+)@(.+$)/.match("foo@example.com")][1..-1]
And it is super readable. username,domain = */([^@]+)@(.+$)/.match("foo@example.com").captures