veer66 boosted

Matz is getting people to weigh in on the |> operator over on the birdsite: twitter.com/yukihiro_matz/stat

My thoughts, having it as an alias for dot operator is meh.

Thinking about trying Ruby 2.7 preview 1 in Docker

鈥漀umbered parameter as the default block parameter鈥 is interesting too, although it is still experimental.

ruby-lang.org/en/news/2019/05/

Ruby 2.7 preview looks a bit similar to Elixir. However, they have worked on the pattern matching since 2012.

speakerdeck.com/k_tsj/pattern-

veer66 boosted

@veer66 it's actually not slow at all. Ruby has a copy-on-write strategy for arrays, so when you grab a subset it will reuse the original array with a different starting offset. Try running a test with different length arrays. On my laptop I get do `x[1..-1]` over 10 million times per second.

veer66 boosted

if 0 in Ruby and if 0 in Python are different.

I use this code "ctx[:lines] = ctx[:lines][1..-1]" very often in , although I know that it is slow. 馃槺

When did I forget that I can use until in Ruby? 馃槶

veer66 boosted

@veer66 imho, `while` and `until` show intent better. although I only use `until` to avoid code like `while x != 0` (which becomes `until x == 0`). Watch out for `until x !=0` (double negations), though

I use

loop do
break if ...
...
end

so often.

Should I turn it to while-loop?

veer66 boosted

Lazy.jl has implemented in Julia my favorite macro which I love from Clojure ^_^

veer66 boosted

@rem @veer66 I'm a big fan of Jeremy Evans' code myself. using Sequel + Roda whenever I can :)

I've run puma on tmux on aarch64 for years. 馃槄

veer66 boosted

@veer66

I guess you want something shorter than this?

p = Pathname.new("a/x/y.z")
p.basename(p.extname)

veer66 boosted

@judofyr @veer66 if you want to keep the s-exp feeling perhaps `File.basename 'a/x/y.z', '.*'` works better

I want this

(pathname-name "a/x/y.z") ;; It returns "y"

in Ruby.

Show more
Ruby.social

A Mastodon instance for Rubyists & friends