简体   繁体   中英

What does ; mean in Ruby?

I am trying to learn how to write plugins in Rails by learning other people's plugins, turns out it is way harder than I thought.

I found this:

module Facebooker

class AdapterBase
    class UnableToLoadAdapter < Exception; end

What does the fourth line: class UnableToLoadAdapter < Exception; end class UnableToLoadAdapter < Exception; end mean?

It's a way of putting multiple expressions on one line.

class UnableToLoadAdapter < Exception
end

is exactly the same as

class UnableToLoadAdapter < Exception; end

Ruby supports ending lines of code with semicolons (;) and allows you to put multiple lines of code onto a single line (for example, x = 10; x += 1; puts x).

Beginning Ruby: From Novice to Professional , 2nd ed. by Peter Cooper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM