€ £ $ ¥ ₽
Thanks to Stack Overflow’s annual survey, we now have this gem (pun intended) of data:
Is this as absurd as it appears? Let’s take a closer look.
Thanks to Stack Overflow’s annual survey, we now have this gem (pun intended) of data:
Is this as absurd as it appears? Let’s take a closer look.
Small adjustment to Tim Pope’s outstanding Effortless Ctags with Git:
To get ctags to also index all bundled gems (including Rails), make the following change to the ctags
hook
Replace
git ls-files | \
ctags --tag-relative -L - -f"$dir/$$.tags" --languages=-javascript,sql
with
ctags --recurse --tag-relative -f"$dir/$$.tags" --languages=-javascript,sql `bundle show --paths` `git ls-files`
After triggering the hook, the tags
file takes a few seconds to generate in the background - have patience :)
That nondescript title is not a placeholder - this post is really about the underscore. It arose out of one of those rewarding moments where you suddenly feel that there must be a way to do something better, and a search quickly reveals that, indeed, there is.
Ever evaluate a complex - particularly multi-line - expression in irb or Rails console and immediately after hitting the Return key realize that you’ve neglected to assign the return value to a variable? Suffer no more:
2.2.0 :001 > [[1,2], [3,4]].map do |pair|
2.2.0 :002 > pair[0]*2 + pair[1]*3
2.2.0 :003 > end
=> [8, 18]
2.2.0 :004 > _
=> [8, 18]
2.2.0 :005 > _.map { |c| c*2 }
=> [16, 36]
See that little line on lines 4 & 5?! Saved by the humble underscore.
Calling the []
method on Hash converts a one-dimensional array with an even number of elements into a hash, with odd/even elements alternating as keys/values. Very cool
2.2.0 :001 > Hash['key1', 'value1', 'key2', 5]
=> {"key1"=>"value1", "key2"=>5}
2.2.0 :002 > Hash['k1', 'v1', 'k2']
=> ArgumentError: odd number of arguments for Hash
This article was originally written as part of an ongoing discussion within the team building the OSRA app.
Any time a component is added to an application, its anticipated benefits must be weighed against the costs of its implementation. Cucumber is a costly framework in terms of development time, developer effort, and cognitive strain on both creators and readers of tests due to the following: