Skip to content
benjchristensen edited this page Jan 25, 2013 · 6 revisions
# Hello World!

A requisite "Hello World!" which creates an Observable from a list of Strings, subscribes to the Observable with a function that will print "Hello %!" for each string.

Groovy

def hello(String[] names) {
    Observable.toObservable(names)
        .subscribe({ println "Hello " + it + "!"})
}
hello("Ben", "George")
Hello Ben!
Hello George!

Clojure

(defn hello
  [&rest]
  (-> (Observable/toObservable &rest)
    (.subscribe #(println (str "Hello " % "!")))))
=> (hello ["Ben" "George"])
Hello Ben!
Hello George!

sidebar

Clone this wiki locally