topics

全部话题 - 话题: strconv
(共0页)
B*****g
发帖数: 34098
1
use telnet at work, no chinese input, try below
SELECT DISTINCT IIF(StrConv(TRIM(left(owner, instr(owner,',')-1)), 3) >=
StrConv(TRIM( mid(owner, instr(owner,',')+1)), 3),
StrConv(TRIM(left(owner, instr(owner,',')-1)), 3) & ','
& StrConv(TRIM( mid(owner, instr(owner,',')+1)), 3),
StrConv(TRIM( mid(owner, instr(owner,',')+1)), 3) & ','
& StrConv(TRIM(left(owner, instr(owner,',')-1)), 3)) AS "OWNER"
FROM [table]

提示
d****n
发帖数: 1637
2
来自主题: Programming版 - 为什么大家不喜欢golang的switch?
switch is fine.
not using switch is only MY choice.
Most functions return very few types of known errors.(one or two)
one is the best or two.
for an example, strconv.ParseInt
if err== strconv.ErrSyntax {
// tell user format wrong
return
}
if err == strconv.ErrRange{
//maybe panic cause you system can not handle bigger than int32
}
it doesn't matter using a switch or if.
error is not C pointer NULL, which doesn't tell any thing.
error is not exception, which you always don't expect it valu... 阅读全帖
d****n
发帖数: 1637
3
来自主题: Programming版 - Be $#%!ing explicit
Example
Consider fetching a user id from a cookie. How much language knowledge do
you need to answer the following questions given the implementation?
What happens if the cookie is not present?
What happens if the cookie value is not a well formatted number?
What happens if the cookie value is a negative number?
Scala
import play.api.mvc.RequestHeader
def getUserId()(implicit request: RequestHeader) = {
request.cookies.get("uid").map(_.value.toLong).filter(_ > 0)
}
Go
import (
"fmt"
"http"... 阅读全帖
p*****2
发帖数: 21240
4
来自主题: Programming版 - 用golang实现了map,大牛给看看?
type Any interface{}
type ArrayOps []interface{}
func (arr ArrayOps) Map(lambda func(Any) Any) ArrayOps {
res := make(ArrayOps, len(arr))
for i, v := range arr {
res[i] = lambda(v)
}
return res
}
func main() {
b := ArrayOps{1, 2, 3, 4, 5}.
Map(func(i Any) Any { return strconv.Itoa(i.(int) * 2) })
fmt.Println(b)
}
(共0页)