Quantcast
Channel: Stack Exchange – Ars Technica
Viewing all articles
Browse latest Browse all 40

In a dynamically typed language, is it a bad idea to return different data types?

$
0
0
In a dynamically typed language, is it a bad idea to return different data types?

(credit: Stack Exchange)

This Q&A is part of a weekly series of posts highlighting common questions encountered by technophiles and answered by users at Stack Exchange, a free, community-powered network of 100+ Q&A sites.

Daniel Kaplan asks:

I come from a statically typed language background (Java). In Java, you have to return a single type from every method. For example, you can't have a method that conditionally returns a String or conditionally returns an Integer. But in JavaScript, for example, this is very possible.

Read 25 remaining paragraphs | Comments


Viewing all articles
Browse latest Browse all 40

Trending Articles