Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

String#ucfirst?

#152

Maybe a String#ucfirst method could be implemented, to capitalize the first character in a String, just like String#capitalize capitalizes the whole string.

Reported by Douwe M. · January 2nd, 2010 @ 08:15 PM

State: new
Milestone: none
Assigned to: MadRabbit MadRabbit

Activity

  1. MadRabbit
    MadRabbit

    Not in the core. There's a whole bunch of additional handy methods over there, and we can't put all of them into the core or we end up with a fat framework and holly mess of methods.

    For this reason there is another plugin called 'lang' that supposedly should keep all additional features and methods for the native units (there are few other similar tickets hanging around). But it wasn't properly developed yet, coz there are more important things to do now.

    January 2nd, 2010 @ 08:40 PM

  2. Douwe M.
    Douwe M.

    Okay, I agree. I thought it would be the same as the #capitalize method, that basically is a mask to #toUpperCase, but then I realized that wasn't true, as #capitalize works for Russian letters too.

    January 2nd, 2010 @ 08:58 PM

  3. MadRabbit
    MadRabbit

    it is actually pretty easy to hack rightjs, if you need this method, you can easily implement it for your case, just like that

    
    $ext(String.prototype, {
      ucfirst: function() {
        return this.replace(/^\s*[a-z]/, function(match) { return match.toUpperCase(); });
      }
    });
    

    January 2nd, 2010 @ 09:16 PM

  4. Douwe M.
    Douwe M.

    Already did myself ;-)

    Which makes me think of this:
    Maybe you could implement the date() function from phpjs.org (at http://phpjs.org/functions/date:380) as Date#format() ? Did that myself already via the $ext() function, but I think this would be a really nice feature to have built right into RightJS, as it actually adds something, unlike ucfirst().

    January 2nd, 2010 @ 09:20 PM

  5. MadRabbit
    MadRabbit

    there is already a ticket for that, but with two corrections, it will follow the POSIX standard not PHP,
    and again it will go in a plugin.

    We will include in the actual core only the things that are necessary for something like 99% of cases. All the fancy features will go in plugins, which can be easily built into the core on the site.

    January 2nd, 2010 @ 09:29 PM

  6. Douwe M.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.