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

Add example of primitive string substitution #496

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

straight-shoota
Copy link
Member

Follow-up on #484 (comment)

/cc @oprypin

@bcardiff
Copy link
Member

I don't think not_nil! should be shown/encouraged in the basic tutorial.

I prefer if/nop or if/raise.

In the methods/classes tutorial we could define a #trust_me_is_not_nil and show the reader there is nothing special about not_nil and then mention its existence in the std-lib.

But presenting it as in this PR sounds like we are encouraging it's use a lot.

@straight-shoota
Copy link
Member Author

I'm not comfortable with promoting .not_nil! either.

But what else could it be? We need some way to make String#index usable. Maybe there should just be String#index! 😆
Conditionals are only introduced in the next lesson...

I suppose we might be able to do something like index || abort "Search string not found". Boolean algebra is also introduced in the next lesson, but maybe it's okay to just say "use this, it'll be explained later".

Any other ideas?

@oprypin
Copy link
Member

oprypin commented Mar 27, 2021

What's wrong with if !search_index.nil?

@straight-shoota
Copy link
Member Author

if gets introduced in the next lesson.

@bcardiff
Copy link
Member

If the tutorials are to be read in strict order, then the things introduced in this PR should not go intro Basic.

Maybe a followup as Text manipulation technique section is a better fit than a basic tutorial. This way you can assume that basic knowledge is covered. I think that from "Indexing Substrings" until the end could be moved out of basic if we do this.

Otherwise I would use if search_index with a reference to the next section. Any other alternative is harder to understand for a newcomer.

My vote is to keep the basics short and have another section to describe more use cases were we can assume all basic tutorial are covered.

@straight-shoota straight-shoota changed the title Add example of primitiv string substitution Add example of primitive string substitution Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants