2016-02-24 130 views
2

分裂一个很长的重量%线我有一个很长的字符串数组,我使用重量%我如何在红宝石

names = %w(FOO BAR BAZZ HELLO WORLD.....) 

这是各地500多个字符长的线写道。 为了便于阅读,我想分割(也称为WRAP)。

什么是推荐的方式?

回答

2

在某些点更改行。

names = %w(
    FOO BAR BAZZ HELLO WORLD 
    FOO BAR BAZZ HELLO WORLD 
    FOO BAR BAZZ HELLO WORLD 
    FOO BAR BAZZ HELLO WORLD 
    FOO BAR BAZZ HELLO WORLD 
    ... 
)