M
Max Williams
Here's a little ruby exercise - i'm a bit brain damaged today and can't
think of a nice way to do this.
I want a method where you pass a name as a string and it returns 'copy
of x' or 'copy 2 of x' eg
new_name("My Lesson")
=> "Copy of My Lesson"
new_name("Copy of My Lesson")
=> "Copy 2 of My Lesson"
new_name("Copy 10 of My Lesson")
=> "Copy 11 of My Lesson"
I can only come up with horrible looking solutions but i feel there's a
nice way to do it. Anyone?
cheers
max
think of a nice way to do this.
I want a method where you pass a name as a string and it returns 'copy
of x' or 'copy 2 of x' eg
new_name("My Lesson")
=> "Copy of My Lesson"
new_name("Copy of My Lesson")
=> "Copy 2 of My Lesson"
new_name("Copy 10 of My Lesson")
=> "Copy 11 of My Lesson"
I can only come up with horrible looking solutions but i feel there's a
nice way to do it. Anyone?
cheers
max