This Week I Learned: 2020-W19

RubyMine code folding, Slack lists, and Ruby weirdness

Published May 10, 2020

Cmd+. toggles code folding in RubyMine

I’ve been writing a lot of RSpec tests for “legacy” code recently. Getting good coverage in this part of the app requires setting values for all the ActiveRecord associations correctly. This is about 20 lines of setup for each case.

RubyMine has a nice mouse affordance for code folding (clicking the handles in the gutter), but I rarely use it because aiming the mouse breaks my programming flow. RubyMine’s Tip of the Day told me about Cmd+. for toggling folds, and these files are so much easier to work in now!

Opt+8 inserts · (MIDDLE DOT) in Slack

When Slack updated to the WYSIWYG editor, I (predictably) hated it. I switched back to “formatting messages with markup” as soon as they enabled that option. However, it seems like that put me into a nearly-plain-text mode instead of the Markdown-like syntax I was used to. I also can’t figure out what the rules are for what it’s capable of rendering. We still have bold, italic, teletype, strikethrough, ordered lists, quotes, and code blocks. But unordered lists and the [display text](href) syntax for links are both broken. The “app surfaces” syntax for links (<href|display text>) doesn’t work either.

It turns out that these limitations are documented. On that page, there’s a workaround for creating bullets for unordered lists: Opt+8. I don’t know if that transfers to non-Mac Slack. (Luckily I don’t need it to.) It doesn’t transfer to non-Slack apps on a Mac. At least now I can make lists at my team again!

Ruby’s splats can coerce anything to an Array

I got this one from 5 Ways to Splat in Ruby, which was featured in this week’s Ruby Weekly.

That article shows an example of coercing an Integer into an Array, but I wanted to see what it would do for more complex values:

x = *{foo: 'bar'}
x # [[:foo, "bar"]]

I, uh…

x = *method(:puts)
x # [#<Method: Object(Kernel)#puts(*)>]


x = *x
x # []