Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Monospace Mentor
@monospace@floss.social  ·  activity timestamp last month

Did you know that you can literally multiply array elements in #Ruby?

`[1, 2, 3] * 3 # => [1, 2, 3, 1, 2, 3, 1, 2, 3]`

And with a scalar string, it’s a shortcut for `join`:

```
h = { a: 1, b: 2}
h.map { |pair| pair * "=" } * ", " # => "a=1, b=2"
```

  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.13 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login