0

I' learning the Opa (opalang.org). I am trying to find out how one can determine the type of a variable. This could be e.g. a function

typeof a // in javascript, this returns the type of a

The API-Documentation contains a description of OpaValue.typeof(a) but I can't find out how to use it.

JanD
  • 7,230
  • 3
  • 23
  • 24

1 Answers1

1

Here is a short example :

int hello = 42
hello_type = OpaValue.typeof(hello)
Log.info("Hello type:", "{hello_type}")

However i am surprised you want to manipulate Opa types. What is your usage ?

Fred
  • 1,092
  • 5
  • 9
  • I use to fiddle around with a language which is new to me and sometimes it is useful to know the type of some thing. In this case I had the line match (HttpRequest.get_method()) { case {some: method}: etc (from http://doc.opalang.org/manual/Hello--web-services) and wanted to find out what some: method means. (especially the some:) – JanD Aug 31 '12 at 19:32
  • 1
    @JanD, `{some: method}` is Opa's syntax for pattern that matches record with one field called `some` and binds the value associated that field to variable called `method`. For instance: `match ({some: 1}) { case {some: x}: x }` should evaluate to 1. Hopefully the example is OK syntactically. – Artyom Shalkhakov Sep 05 '12 at 03:33