简体   繁体   English

什么 在Elixir做

[英]What does ? do in Elixir

I am aware of String.strip/2 , but I cannot figure out its usage for removing whitespaces. 我知道String.strip/2 ,但我无法弄清楚它用于删除空格的用法。

String.strip "_some_", ?_   #=> "some"

If the string had whitespaces instead of _, how does one strip them? 如果字符串有空格而不是_,那么如何删除它们? Also, it would be great if someone can explain what ? 而且,如果有人可以解释什么,那会很棒吗? means here. 在这里意味着

字符前面的问号返回其代码点,它在入门指南的这一部分中提到: http//elixir-lang.org/getting-started/binaries-strings-and-char-lists.html

There's String.strip/1 which strips all unicode whitespace. String.strip/1 ,它会删除所有unicode空格。 So you can just 所以你可以

iex(2)> String.strip("\t\ntest   ")
"test"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM