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

Suggest heredocs for multiline string wraps #586

Open
charlesrocket opened this issue Feb 13, 2022 · 2 comments
Open

Suggest heredocs for multiline string wraps #586

charlesrocket opened this issue Feb 13, 2022 · 2 comments

Comments

@charlesrocket
Copy link

charlesrocket commented Feb 13, 2022

Suggest heredocs as main way to wrap multiple lines of strings due its ability to remove leading whitespaces.

@straight-shoota
Copy link
Member

Thanks for bringing this up. Could you be a bit more specific, though? Where do you suggest to use heredoc? What kind of action would you expect from this issue? Thanks!

@Blacksmoke16
Copy link
Member

To add some context, this discussion came up on Discord, with the gist of it being when using a multiline string in a nested namespace like:

module MyApp
  INTRO = "
  foo
  bar"
end

That the extra whitespace before foo and bar is unexpected, and you have to do like:

module MyApp
  INTRO = "
foo
bar"
end

to remove them, which forces you to ignore the indentation of the constant.

The thinking behind this issue is to add something to https://crystal-lang.org/reference/1.3/syntax_and_semantics/literals/string.html#multiline-strings to suggest you most likely want to use a heredoc, as afaik, a heredoc can do everything a multiline string can do, but in a more idiomatic way. Or in other words, essentially deprecate multiline strings in favor of heredocs within the documentation.

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

No branches or pull requests

3 participants