官术网_书友最值得收藏!

A practical implementation

Now, you may be wondering why it's helpful to manipulate strings. It's cool to see, but is there any practical value? Let me walk you through a real-world case study to illustrate the importance of string manipulation.

Whenever I'm building a search engine inside an application that I'm working on, there are many times where I need to convert the case of either the value being searched for or the value from the database. For example, if a user wants to search for the Milk word, it's highly likely that my database query will not return the associated record or information because it does not handle case sensitivity well by default. If I have the milk word in my database, it wouldn't be returned because database searches are case sensitive. On the other hand, if I convert the entire word to an uppercase or lowercase value, depending on how the database is setup, the database query will work properly and return the correct results. This is one example of the importance of string manipulation in programming.

With regard to string manipulation, we've only touched the basics. Refer to the String class documentation (http://ruby-doc.org/core-2.2.0/String.html) to see the full list of methods.

主站蜘蛛池模板: 永仁县| 布尔津县| 武宁县| 手游| 斗六市| 云梦县| 启东市| 正定县| 连州市| 义马市| 冕宁县| 师宗县| 驻马店市| 盖州市| 吉隆县| 黄大仙区| 巩义市| 桂阳县| 太仆寺旗| 玛曲县| 博兴县| 海晏县| 遂昌县| 海南省| 光泽县| 巴彦淖尔市| 菏泽市| 海兴县| 云南省| 通海县| 开封市| 马关县| 修水县| 茶陵县| 平昌县| 原阳县| 安新县| 沙湾县| 仁怀市| 贺州市| 安塞县|