User:AJFarmar: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 11:
==Ruby==
===Recent code:===
I made a little method that allowed me to replace <langcode ruby>"String".split(" ")[index]</langcode> with <code ruby>"String".word index</code>.
I know that this is relatively simple, but I still found it kinda neat.
 
<lang ruby>
class String
 
def word(index)
return self.split(" ")[index] if index.class != Range
return self.split(" ")[index].join(" ")
end
 
end
</lang>
Anonymous user