Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement String prepend #410

Merged
merged 3 commits into from
Jan 12, 2022
Merged

Conversation

TheGrizzlyDev
Copy link
Contributor

Mostly based around String#concat with some very minor differences

References: #217

str_obj->assert_type(env, Object::Type::String, "String");
appendable.append(str_obj->c_str());
}
m_string.prepend(appendable.c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that @FnControlOption worked on was making our String class properly handle internal null characters \0. I think we need to avoid dropping down to cstrs as much as possible for that reason.

s = "foo"
s.prepend("bar\0baz")
p s # => "bar\u0000bazfoo"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to add a String::prepend() that accepts another String....

@seven1m seven1m merged commit 2f258f8 into natalie-lang:master Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants