Yehuda Katz<\/a> later pointed to me that this can actually be done with any of the three unary operators in Ruby: +, – and ~.<\/p>\nSo we could also do:<\/p>\n
\r\nclass String\r\n def +@\r\n upcase\r\n end\r\n\r\n def -@\r\n downcase\r\n end\r\nend\r\n<\/pre>\nAnd now:<\/p>\n
\r\n+\"jose\" #=> \"JOSE\"\r\n-\"JOSE\" #=> \"jose\"\r\n<\/pre>\nYou could even “go crazy” and append several unary operators:<\/p>\n
\r\n+-+\"jose\" #=> \"JOSE\"\r\n<\/pre>\nAnd you? Did you know such behavior in Ruby? Do you have any good use case for it?<\/p>\n","protected":false},"excerpt":{"rendered":"
Pratik lately is doing a great work refactoring ActiveRecord to make a full use of relations. Speaking in code language, this means that in Rails 3 you will be able to do: User.where(:name => “Jose”).order(“birthday”) And it will return a relation. The relation can be further manipulated and the query is only triggered when you … \u00bb<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[62,60,61],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/555"}],"collection":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/comments?post=555"}],"version-history":[{"count":7,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/555\/revisions"}],"predecessor-version":[{"id":565,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/555\/revisions\/565"}],"wp:attachment":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/media?parent=555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/categories?post=555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/tags?post=555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}