|
From: | Dmitry Gutov |
Subject: | Re: On removing some obsolete code from subr and core |
Date: | Sat, 5 Nov 2016 19:31:03 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Thunderbird/50.0 |
On 05.11.2016 19:23, Clément Pit--Claudel wrote:
ELISP> (string-to-number "abc") 0 (#o0, #x0, ?\C-@) ELISP> (string-to-number "22.2abc") 22.2I know, I know :) (what is this fancy ELISP repl, btw?)
M-x ielm. :)
Hmm. I'd expect string-to-int to error on non-ints:int("1.3")Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '1.3'
No so in Elisp. Or JavaScript: > parseInt("123abc") => 123 ¯\_(ツ)_/¯ If you really need to error, string-match-p is probably your best bet.
[Prev in Thread] | Current Thread | [Next in Thread] |