Custom usage of %w in Ruby
来源:互联网 发布:手机淘宝店铺怎么描述 编辑:程序博客网 时间:2024/05/14 21:47
I know that %w
or %W
is 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.
0 0
- Custom usage of %w in Ruby
- Usage of hash in Perl
- Usage of Array in Perl
- Usage of Cursor in Oracle Procedure
- Usage of Global:: prefix in C#
- the usage of dict in python
- the usage of tuple in python
- Custom fields of Organization in Liferay
- Db Attribute(Custom ORM ) Usage
- Summary on 20080616: Basic usage of Enum in Java1.5
- How to discover memory usage of my application in Android
- How to discover memory usage of my application in Android
- Usage of uvent,bind and unbind interface in /sys
- How to discover memory usage of my application in Android
- 【DataStructure】Charming usage of Set in the java
- How to discover memory usage of my application in Android
- life of a memory request in ruby
- Sorting an array of hash in Ruby
- 【ACM之旅】计算价格
- 蛇与梯子游戏 (BFS + priority_queue)
- Httpclient(模拟用户发送请求)
- 柔性数组
- 小学生晋级之非对称加密算法-RSA
- Custom usage of %w in Ruby
- YUV格式详解
- servlet 的过滤机制练习
- 分布式系统--开篇
- PAT 1006. 换个格式输出整数
- 面试中C语言--数据转换
- 浙江杭州1040阳光工程叫家里人来投资违不违法?能不能赚到钱?
- 简单好用的小控件 ------UISwitchButton
- oracle 时间比较sql