Custom usage of %w in Ruby
2015-03-03 15:53
211 查看
I know that
used for constructing an array of strings. But I have a custom requirement:
Using
I would like to get the following array pattern:
Is it possible?
The space between the strings are making issues.
Thanks for any help offered :)
-----------------------------------------------------------------------------------
You'll have to use character escaping to escape the space, like so:
Though not sure if that reads any clearer than putting them in quotes.
%wor
%Wis
used for constructing an array of strings. But I have a custom requirement:
Using
%w,
I would like to get the following array pattern:
["First Name", "Middle Name", "Last Name", "Email"]
Is it possible?
The space between the strings are making issues.
Thanks for any help offered :)
-----------------------------------------------------------------------------------
You'll have to use character escaping to escape the space, like so:
result = %w(First\ Name Middle\ Name Last\ Name Email)
Though not sure if that reads any clearer than putting them in quotes.
相关文章推荐
- How to access body of Custom tags in JSP tutorial
- The Usage of Lambda and Heap in the C++ STL
- the usage of tuple in python
- Summary on 20080616: Basic usage of Enum in Java1.5
- how to merge array of hash based same keys in ruby?
- An example usage of an encryption algorithm (AES, in this case) is:
- Usage of uvent,bind and unbind interface in /sys
- Getting the indexes of duplicate elements in arrays (Ruby)
- Custom fields of Organization in Liferay
- Usage of Cursor in Oracle Procedure
- Concurrent use of embedded Ruby in Java (using JRuby)
- Get nth element of an array in Ruby?
- Converting a array to an array of ranges in ruby
- Use of UUID(Universally unique identifier) in Ruby On Rails Application.
- Usage of hash in Perl
- Adding a custom method in an ADF BC Service Interface – update of a single attribute in a selected r
- Demo of use SQL (Insert logs in system resource usage table)使用sql 的一个示例(插入系统使用日志数据)
- 使用autolayout在iOS7系统崩溃,提示为:*** Assertion failure in -[CustomClass layoutSublayersOfLayer:]
- the usage of Properties in java.util
- .Net EF Core数据库使用SQL server 2008 R2分页报错How to avoid the “Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement.”