Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/docPublic

Tighten Up Augment Example #4533

Open
Open
Labels
docsDocumentation issue (primary issue type)
@librasteve

Description

@librasteve

Problem

https://docs.raku.org/language/variables#The_augment_declarator

The better usage example has confused some readers:

For a better, and safer example, this is a practical way to create a class module to extend IO::Path by adding a currently missing method to yield the part of the basename left after the extension is removed. (Note there is no clear developer consensus about what to call that part or even how it should be constructed.)

unit class IO::Barename is IO::Path; method new(|c) {    return self.IO::Path::new(|c);} use MONKEY-TYPING;augment class IO::Path {    method barename {        self.extension("").basename;    }}

Here is a recent exchange on IRC:

<botato> I'm a little confused reading the documentation for augment at https://docs.raku.org/language/variables[03:05]  Raku bridge: <botato> it says "For a better, and safer example, this is a practical way to create a class module to extend IO::Path by adding a currently missing method", does "unit class IO::Barename is IO::Path;" and then "augment class IO::Path {"[03:06]  Raku bridge: <botato> if i understand I think the intent was to make IO::Barename that is like IO::Path but with the barename method added[03:07]  Raku bridge: <botato> but the example actually monkeypatched the barename method onto IO::Path, was that a mistake and it's supposed to be "augment class IO::Barename" or am I not understanding what's going on?[03:41]  Raku bridge: <ugexe> i dont understand what it is trying to say[03:43]  Raku bridge: <ugexe> i also don't understand what the example is trying to do

Suggestions

Edited in the light that there is no such thing asbetter and safer augment...

** I suggest that we delete the above paragraph and example entirely **

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation issue (primary issue type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp