定义一个类时"<"是什么意思?

Nei*_*nto 1 ruby syntax

我有这个由rails生成的Ruby代码:

class PostsController < ApplicationController
Run Code Online (Sandbox Code Playgroud)

什么<意思?

Gag*_*ami 6

<用于继承.在Ruby中,类只能从一个其他类继承.

class PostsController <ApplicationController

上面的代码行PostsController(子类)继承自ApplicationController父类.

在Rails中:

Action Controllers是Rails中Web请求的核心.默认情况下,只有ApplicationControllerRails应用程序中的继承自ActionController::Base.所有其他控制器都继承自ApplicationController.这为您提供了一个类来配置请求伪造保护和过滤敏感请求参数等内容.

了解更多信息: