We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 16: Exceptions - String to Integer
Day 16: Exceptions - String to Integer
Sort by
recency
|
987 Discussions
|
Please Login in order to post a comment
Here's the ugly Typescript that doesn't use conditionals, lol.
I don't think you can actually complete this task using Typescript as the resulting number is just NaN and throwing your own error will fail becasue you have an if statement.
Hey, Here is my code : " if name == 'main': a = input() try: print(int(a)) except Exception: print('Bad String') " and the rerult is: "Error reading result file.You should use exception handling concepts."
help me please :)
import Foundation
/* * Define an ErrorType */ enum StringToIntTypecastingError: Error { case BadString }
/* * Read the input */ let inputString = readLine()!
do { try print(stringToInt(inputString: inputString)) } catch StringToIntTypecastingError.BadString { print("Bad String") }
**// I am getting Error reading result file.You should use exception handling concepts.
but output printing correct can any one please help in this in Swift language **