Skip to content

str has no rfind, bytes() or trim_start(): a one-off With tool had to hand-roll each #2206

Closed

Description

@ehartford

Writing tools/pub_private_methods.w (#2186) as a With script, three ordinary string operations were unknown method … for type 'str':

  • s.rfind(":"): the last occurrence (split on a path:line pair). Worked around with split(":") and slicing.
  • for b in s.bytes(): iterate the bytes. Worked around with for i in 0..s.len(): s[i].
  • s.trim_start() / trim_end(): the indentation and the rest of a line. Worked around with a while loop over ' ' and '\\t'.

These are the same class as #959 (one-liner text conveniences): each is what a sed/awk/perl one-liner reaches for, and AGENTS.md requires these tools be written in With.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions