Ruby

716 readers
2 users here now

A community for discussion and news about Ruby programming.

Learning Ruby?

Tools

Documentation

Books

Screencasts

News and updates

founded 2 years ago
MODERATORS
26
27
28
29
30
31
 
 

I wasn't able to find any up-to-date information about tail call optimization support in Ruby, so I decided to post this hoping that it will pop up next time someone might also be searching for this topic...

What I was able to figure out is that TCO can be enabled in Ruby 3.4 via a compile option like so:

RubyVM::InstructionSequence.compile_option = {tailcall_optimization: true}

def tailSumUntil(n, m)
  n == 0 ? m : tailSumUntil(n - 1, n + m)
end

tailSumUntil(100_000_000, 0)
# => 5000000050000000
32
 
 

Hi
What is Primitive in the MRI context?

Why did a lot of things get rewritten into Primitive?
Is there some official documentation about it?

33
34
35
36
37
38
39
40
41
1
submitted 2 years ago* (last edited 2 years ago) by mac@programming.dev to c/ruby@programming.dev
42
43
44
45
 
 

I saw a project a couple weeks back which allows writing and running Crystal methods inline inside a Ruby file. It’s a neat project, and I don’t want to take away from it but something in the README example looked off to me. require 'crystalruby' require 'benchmark' module Fibonnaci crystalize [n:

46
47
 
 

The Neonify challenge on Hack The Box is a small Sinatra(a Ruby web framework) app, that generates a glowing text of the submitted value:

48
 
 

All new applications using Rails 8 will have rubocop gem by default.

49
50
view more: ‹ prev next ›