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

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.

主站蜘蛛池模板: 岑溪市| 磐石市| 新龙县| 卢氏县| 宣恩县| 乳山市| 永吉县| 陇川县| 南汇区| 社会| 轮台县| 合水县| 类乌齐县| 南京市| 桐柏县| 张北县| 凤庆县| 张家港市| 保山市| 开阳县| 平顺县| 姚安县| 义马市| 南平市| 景德镇市| 谢通门县| 淳化县| 华阴市| 舞阳县| 南漳县| 微山县| 九江市| 浦城县| 黄浦区| 兰溪市| 张家港市| 河西区| 富民县| 安远县| 云梦县| 徐汇区|