Tuesday, May 1, 2012

스트링 입력 받아 수로 바꾸기

 line = io.read() -- read a line  
 n = tonumber(line) -- try to convert it to a number  
 if n == nil then  
      error(line .. " is not a valid number")  
 else  
      print(n*2)  
 end     
키워드 : input, string, number, 숫자
출처 : Programming in Lua, Second Edition - 2006 - by Roberto Ierusalimschy

No comments:

Post a Comment