Why not `module_function` is accesible inside the class scope?

The below code is running properly :

module Mod
def one
“This is one”
end
module_function :one
end

Below is throwing error :

class Mod
def one
“This is one”
end
module_function :one
end

~> -:5:in <class:Mod>': undefined methodmodule_function’ for

Mod:Class (NoMethodError)

~> from -:1:in `’

Why is such design?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs