wow...nobody likes ruby...poor ruby:(
Also if you had used the same formating for the Ruby as python and php it would be about the same length so there is no real gain on that statement
True...
I did say that I still prefered the python approach over ruby to iterating over a collection. It's just as concise and easier to read. In my mind Python wins this comparison.
php resorts to the type specific
strlen function and a string concatination. I don't like that. Is there any other way to find the length of a string in php? Not that i'm aware of...
I like how ruby has the length of the string as a method of a string object.
"myString".length
python's len() function takes a sequence object, which includes strings, as an argument. Not as clean, but a least I only have on function to remember for lists, strings, and tuples.
myString = "test"
myList = ['list']
myTuple = ('tuple')
print len(myString), len(myList), len(myTuple)
The php approach takes a different function for each type, string or array.
$myString = "test";
$myArray = array("array");
echo strlen($myString) . "\n";
echo count($myArray) . "\n";
This is a trend that present throughout php. There's also an annoying lack of inconsistency with how the functions are named. I always have to check documentation for the correct name of the function I'm thinking of. Is it
is_array() or
isarray()....
isset() or
is_set()