Split a string in two (or three)

June 27, 2009 at 10:07 am Leave a comment

@lat, @lng, @zoom = @location.split(',')

This simple line will take the string @location, split it based on the comma into three strings. If location is “a,b”, then @zoom will be empty.

You will need to validate your user’s input of course, but it’s one of the ways how Ruby makes some basic tasks easy.


Entry filed under: Uncategorized. Tags: , .

Google Maps API in Rails (YM4R-GM) – Part II: Usage Learning to read Ruby on Rails code – a cheatsheet for absolute beginners

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

Recent posts

Starting to learn Rails?


Get Kindle - the best e-book reader, that I personally use, and the only one that you can read on the beach - very useful: Kindle Wireless Reading Device (6" Display, Global Wireless, Latest Generation)

%d bloggers like this: