When I look at the source code of the library with python or ruby, it comes up a little.
The keyword klass
.
Although I was sensuously thinking "There is no such word in English ...", I went through it until a long time ago, but recently I came back when I hacked the contents of a certain ruby library. So I looked it up.
You may not know what you are saying, but for example
def inspect_class(class)
puts class.class
end
inspect_class('a')
When you want to write the code.
This will result in a syntax error.
Because the keyword class
is already defined as a reserved word in ruby.
At that time
def inspect_class(klass)
puts klass.class
end
inspect_class('a')
It will pass properly.
Imagewise
It is an impression that it is often written as an argument name of a method such as.
Especially in ruby's ActiveRecord, class (model) is often passed as an argument. (Rather, most frameworks do that.)
I wonder if the keyword klass
often appears in the ruby industry.
So, inspired by that, I feel like using python or something called klass
.
klass
, but it is just written in ** so that it is easy to understand that you are passing a class.
Depending on the person (project, etc.), it may be called clazz
, and as I received in the comments, it is also written as cls
in python.As far as I can see the flow of the source, I believe that it is very important to hone my skills to investigate with interest in what I wondered, even though I thought "I'm sure that's the case", slightly or unconsciously. I will.
https://stackoverflow.com/questions/4299289/what-is-the-difference-between-class-and-klass-in-ruby
Recommended Posts